Options

How to count objects in image using RapidMiner and applied to Python coding?

wig_2006wig_2006 Member Posts: 1 Contributor I
I try to create image processing with MCIO (multiple_color_image_opener) in RapidMiner to can recognize image to apple or orange but cannot count objects in image using RapidMiner and applied to Python coding.

Concept count objects in image to using in RapidMiner link - https://stackoverflow.com/questions/38619382/how-to-count-objects-in-image-using-python

YouTube link to learning create image processing with MCIO (multiple_color_image_opener) in RapidMiner - https://www.youtube.com/watch?v=dsTJWXtc7oo

Process file (.rmp file) in RapidMiner link


XML description in RapidMiner file

1. count apple + orange.rmp

<?xml version="1.0" encoding="UTF-8"?><process version="10.1.002">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="10.1.002" expanded="true" name="Process">
    <parameter key="logverbosity" value="init"/>
    <parameter key="random_seed" value="2001"/>
    <parameter key="send_mail" value="never"/>
    <parameter key="notification_email" value=""/>
    <parameter key="process_duration_for_mail" value="30"/>
    <parameter key="encoding" value="SYSTEM"/>
    <process expanded="true">
      <operator activated="true" class="imageprocessing:multiple_color_image_opener" compatibility="1.4.001" expanded="true" height="68" name="MCIO" width="90" x="179" y="34">
        <parameter key="datamanagement" value="double_array"/>
        <list key="images">
          <parameter key="apple" value="C:\Users\sumate\Documents\RapidMiner\Repositories\ITE525\processes\train image\unseen\apple"/>
          <parameter key="orange" value="C:\Users\sumate\Documents\RapidMiner\Repositories\ITE525\processes\train image\unseen\orange"/>
        </list>
        <parameter key="auto_adjust_contrast" value="false"/>
        <parameter key="set_mask" value="false"/>
        <parameter key="mask_foldername" value="fitness"/>
        <parameter key="extension" value="ALL IMAGES"/>
        <parameter key="assign_label" value="true"/>
        <parameter key="filter_by_orientation" value="false"/>
        <parameter key="orientation" value="SAGITTAL"/>
        <parameter key="include_unknown_orientation" value="false"/>
        <parameter key="ignore_errors" value="false"/>
        <process expanded="true">
          <operator activated="true" class="imageprocessing:global_feature_extraction" compatibility="1.4.001" expanded="true" height="68" name="Global Feature Extractor from a Single Image" width="90" x="447" y="34">
            <parameter key="include_position_filename" value="false"/>
            <process expanded="true">
              <operator activated="true" class="imageprocessing:statistics" compatibility="1.4.001" expanded="true" height="68" name="Global statistics" width="90" x="447" y="34">
                <parameter key="Mean" value="true"/>
                <parameter key="Median" value="true"/>
                <parameter key="Standard Deviation" value="true"/>
                <parameter key="Skewness" value="false"/>
                <parameter key="Kurtosis" value="false"/>
                <parameter key="Peak" value="true"/>
                <parameter key="Min Gray Value" value="true"/>
                <parameter key="Max Gray Value" value="true"/>
                <parameter key="Center of Mass" value="false"/>
                <parameter key=" Normalized Center of Mass" value="false"/>
                <parameter key="Area Fraction" value="false"/>
                <parameter key="Edginess" value="true"/>
                <parameter key="Thickness" value="1"/>
              </operator>
              <connect from_port="color image plus 1" to_op="Global statistics" to_port="color image plus"/>
              <connect from_op="Global statistics" from_port="features" to_port="feature 1"/>
              <portSpacing port="source_color image plus 1" spacing="0"/>
              <portSpacing port="source_color image plus 2" spacing="0"/>
              <portSpacing port="sink_feature 1" spacing="0"/>
              <portSpacing port="sink_feature 2" spacing="0"/>
            </process>
          </operator>
          <connect from_port="color image plus" to_op="Global Feature Extractor from a Single Image" to_port="color image plus"/>
          <connect from_op="Global Feature Extractor from a Single Image" from_port="example set" to_port="Example set"/>
          <portSpacing port="source_color image plus" spacing="0"/>
          <portSpacing port="sink_Example set" spacing="0"/>
        </process>
      </operator>
      <operator activated="true" class="write_excel" compatibility="10.1.002" expanded="true" height="103" name="Write Excel" width="90" x="447" y="34">
        <parameter key="excel_file" value="C:\Users\sumate\Documents\RapidMiner\Repositories\ITE525\processes\train image\unseen\count apple + orange.xlsx"/>
        <parameter key="file_format" value="xlsx"/>
        <enumeration key="sheet_names"/>
        <parameter key="sheet_name" value="RapidMiner Data"/>
        <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/>
        <parameter key="number_format" value="#.0"/>
        <parameter key="encoding" value="SYSTEM"/>
      </operator>
      <connect from_op="MCIO" from_port="example set" to_op="Write Excel" to_port="input"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
    </process>
  </operator>
</process>

2. algorithms train apple + orange.rmp

<?xml version="1.0" encoding="UTF-8"?><process version="10.1.002">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="10.1.002" expanded="true" name="Process">
    <parameter key="logverbosity" value="init"/>
    <parameter key="random_seed" value="2001"/>
    <parameter key="send_mail" value="never"/>
    <parameter key="notification_email" value=""/>
    <parameter key="process_duration_for_mail" value="30"/>
    <parameter key="encoding" value="SYSTEM"/>
    <process expanded="true">
      <operator activated="true" class="imageprocessing:multiple_color_image_opener" compatibility="1.4.001" expanded="true" height="68" name="MCIO" width="90" x="179" y="34">
        <parameter key="datamanagement" value="double_array"/>
        <list key="images">
          <parameter key="apple" value="C:\Users\sumate\Documents\RapidMiner\Repositories\ITE525\processes\train image\seen\apple"/>
          <parameter key="orange" value="C:\Users\sumate\Documents\RapidMiner\Repositories\ITE525\processes\train image\seen\orange"/>
        </list>
        <parameter key="auto_adjust_contrast" value="false"/>
        <parameter key="set_mask" value="false"/>
        <parameter key="mask_foldername" value="fitness"/>
        <parameter key="extension" value="ALL IMAGES"/>
        <parameter key="assign_label" value="true"/>
        <parameter key="filter_by_orientation" value="false"/>
        <parameter key="orientation" value="SAGITTAL"/>
        <parameter key="include_unknown_orientation" value="false"/>
        <parameter key="ignore_errors" value="false"/>
        <process expanded="true">
          <operator activated="true" class="imageprocessing:global_feature_extraction" compatibility="1.4.001" expanded="true" height="68" name="Global Feature Extractor from a Single Image" width="90" x="447" y="34">
            <parameter key="include_position_filename" value="false"/>
            <process expanded="true">
              <operator activated="true" class="imageprocessing:statistics" compatibility="1.4.001" expanded="true" height="68" name="Global statistics" width="90" x="447" y="34">
                <parameter key="Mean" value="true"/>
                <parameter key="Median" value="true"/>
                <parameter key="Standard Deviation" value="true"/>
                <parameter key="Skewness" value="false"/>
                <parameter key="Kurtosis" value="false"/>
                <parameter key="Peak" value="true"/>
                <parameter key="Min Gray Value" value="true"/>
                <parameter key="Max Gray Value" value="true"/>
                <parameter key="Center of Mass" value="false"/>
                <parameter key=" Normalized Center of Mass" value="false"/>
                <parameter key="Area Fraction" value="false"/>
                <parameter key="Edginess" value="true"/>
                <parameter key="Thickness" value="1"/>
              </operator>
              <connect from_port="color image plus 1" to_op="Global statistics" to_port="color image plus"/>
              <connect from_op="Global statistics" from_port="features" to_port="feature 1"/>
              <portSpacing port="source_color image plus 1" spacing="0"/>
              <portSpacing port="source_color image plus 2" spacing="0"/>
              <portSpacing port="sink_feature 1" spacing="0"/>
              <portSpacing port="sink_feature 2" spacing="0"/>
            </process>
          </operator>
          <connect from_port="color image plus" to_op="Global Feature Extractor from a Single Image" to_port="color image plus"/>
          <connect from_op="Global Feature Extractor from a Single Image" from_port="example set" to_port="Example set"/>
          <portSpacing port="source_color image plus" spacing="0"/>
          <portSpacing port="sink_Example set" spacing="0"/>
        </process>
      </operator>
      <operator activated="true" class="concurrency:cross_validation" compatibility="10.1.002" expanded="true" height="145" name="Validation" width="90" x="380" y="34">
        <parameter key="split_on_batch_attribute" value="false"/>
        <parameter key="leave_one_out" value="false"/>
        <parameter key="number_of_folds" value="10"/>
        <parameter key="sampling_type" value="stratified sampling"/>
        <parameter key="use_local_random_seed" value="false"/>
        <parameter key="local_random_seed" value="1992"/>
        <parameter key="enable_parallel_execution" value="true"/>
        <process expanded="true">
          <operator activated="false" class="concurrency:parallel_decision_tree" compatibility="10.1.002" expanded="true" height="103" name="Decision Tree" width="90" x="179" y="34">
            <parameter key="criterion" value="information_gain"/>
            <parameter key="maximal_depth" value="10"/>
            <parameter key="apply_pruning" value="false"/>
            <parameter key="confidence" value="0.1"/>
            <parameter key="apply_prepruning" value="false"/>
            <parameter key="minimal_gain" value="0.01"/>
            <parameter key="minimal_leaf_size" value="2"/>
            <parameter key="minimal_size_for_split" value="4"/>
            <parameter key="number_of_prepruning_alternatives" value="3"/>
          </operator>
          <operator activated="true" class="concurrency:parallel_random_forest" compatibility="10.1.002" expanded="true" height="103" name="Random Forest" width="90" x="179" y="238">
            <parameter key="number_of_trees" value="100"/>
            <parameter key="criterion" value="information_gain"/>
            <parameter key="maximal_depth" value="10"/>
            <parameter key="apply_pruning" value="false"/>
            <parameter key="confidence" value="0.1"/>
            <parameter key="apply_prepruning" value="false"/>
            <parameter key="minimal_gain" value="0.01"/>
            <parameter key="minimal_leaf_size" value="2"/>
            <parameter key="minimal_size_for_split" value="4"/>
            <parameter key="number_of_prepruning_alternatives" value="3"/>
            <parameter key="random_splits" value="false"/>
            <parameter key="guess_subset_ratio" value="true"/>
            <parameter key="subset_ratio" value="0.2"/>
            <parameter key="voting_strategy" value="confidence vote"/>
            <parameter key="use_local_random_seed" value="false"/>
            <parameter key="local_random_seed" value="1992"/>
            <parameter key="enable_parallel_execution" value="true"/>
          </operator>
          <connect from_port="training set" to_op="Random Forest" to_port="training set"/>
          <connect from_op="Random Forest" from_port="model" to_port="model"/>
          <portSpacing port="source_training set" spacing="0"/>
          <portSpacing port="sink_model" spacing="0"/>
          <portSpacing port="sink_through 1" spacing="0"/>
          <description align="left" color="green" colored="true" height="80" resized="true" width="248" x="37" y="158">In the training phase, a model is built on the current training data set. (90 % of data by default, 10 times)</description>
        </process>
        <process expanded="true">
          <operator activated="true" class="apply_model" compatibility="10.1.002" expanded="true" height="82" name="Apply Model" width="90" x="45" y="34">
            <list key="application_parameters"/>
          </operator>
          <operator activated="true" class="performance" compatibility="10.1.002" expanded="true" height="82" name="Performance" width="90" x="179" y="34">
            <parameter key="use_example_weights" value="true"/>
          </operator>
          <connect from_port="model" to_op="Apply Model" to_port="model"/>
          <connect from_port="test set" to_op="Apply Model" to_port="unlabelled data"/>
          <connect from_op="Apply Model" from_port="labelled data" to_op="Performance" to_port="labelled data"/>
          <connect from_op="Performance" from_port="performance" to_port="performance 1"/>
          <connect from_op="Performance" from_port="example set" to_port="test set results"/>
          <portSpacing port="source_model" spacing="0"/>
          <portSpacing port="source_test set" spacing="0"/>
          <portSpacing port="source_through 1" spacing="0"/>
          <portSpacing port="sink_test set results" spacing="0"/>
          <portSpacing port="sink_performance 1" spacing="0"/>
          <portSpacing port="sink_performance 2" spacing="0"/>
          <description align="left" color="blue" colored="true" height="103" resized="true" width="315" x="38" y="158">The model created in the Training step is applied to the current test set (10 %).&lt;br/&gt;The performance is evaluated and sent to the operator results.</description>
        </process>
        <description align="center" color="transparent" colored="false" width="126">A cross-validation evaluating a decision tree model.</description>
      </operator>
      <operator activated="true" class="read_excel" compatibility="10.1.002" expanded="true" height="68" name="Read Excel" width="90" x="179" y="289">
        <parameter key="excel_file" value="C:\Users\sumate\Documents\RapidMiner\Repositories\ITE525\processes\train image\unseen\count apple + orange.xlsx"/>
        <parameter key="sheet_selection" value="sheet number"/>
        <parameter key="sheet_number" value="1"/>
        <parameter key="imported_cell_range" value="A1"/>
        <parameter key="encoding" value="SYSTEM"/>
        <parameter key="first_row_as_names" value="true"/>
        <list key="annotations"/>
        <parameter key="date_format" value=""/>
        <parameter key="time_zone" value="SYSTEM"/>
        <parameter key="locale" value="English (United States)"/>
        <parameter key="read_all_values_as_polynominal" value="false"/>
        <list key="data_set_meta_data_information"/>
        <parameter key="read_not_matching_values_as_missings" value="true"/>
      </operator>
      <operator activated="true" class="apply_model" compatibility="10.1.002" expanded="true" height="82" name="Apply Model (2)" width="90" x="581" y="289">
        <list key="application_parameters"/>
      </operator>
      <connect from_op="MCIO" from_port="example set" to_op="Validation" to_port="example set"/>
      <connect from_op="Validation" from_port="model" to_op="Apply Model (2)" to_port="model"/>
      <connect from_op="Read Excel" from_port="output" to_op="Apply Model (2)" to_port="unlabelled data"/>
      <connect from_op="Apply Model (2)" from_port="labelled data" to_port="result 1"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
    </process>
  </operator>
</process>

Image to describe process in RapidMiner.

1. count apple + orange.rmp - https://i.imgur.com/4Rhgkpg.png
2. algorithms train apple + orange.rmp - https://i.imgur.com/KBObOcJ.png
Sign In or Register to comment.