RapidMiner

RapidMiner

[SOLVED] Image Mining: Color Histogram

[SOLVED] Image Mining: Color Histogram

Hello,

I would like to ask what is the best strategy for extracting color histograms and specifically HSV.

In the following workflow I am trying to extract Hue, Saturation and Value like tis:
- Multiple Color Image Opener
 -Global Feature Extraction from Single Image
   -Color to Grayscale->Grayscale to Color->Histogram (performed 3 times, one for H, one for S and one for V)

I get the exception: Duplicate attribute name Histogram0.

Is this the correct way to extract histograms, or is there something wrong with the workflow?

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.008">
 <context>
   <input/>
   <output/>
   <macros/>
 </context>
 <operator activated="true" class="process" compatibility="5.3.008" expanded="true" name="Process">
   <parameter key="logfile" value="C:\Users\Elena\Dropbox\Master\Thesis\RapidMiner\logfile\log.txt"/>
   <parameter key="resultfile" value="C:\Users\Elena\Dropbox\Master\Thesis\RapidMiner\resultfile\resultfile.txt"/>
   <process expanded="true">
     <operator activated="true" class="imageprocessing:multiple_color_image_opener" compatibility="1.4.001" expanded="true" height="60" name="MCIO(H)" width="90" x="45" y="30">
       <list key="images">
         <parameter key="city" value="C:\Users\Elena\Dropbox\Master\Thesis\mcio"/>
       </list>
       <parameter key="auto_adjust_contrast" value="true"/>
       <process expanded="true">
         <operator activated="true" class="imageprocessing:global_feature_extraction" compatibility="1.4.001" expanded="true" height="60" name="Global Feature Extractor from a Single Image" width="90" x="246" y="75">
           <parameter key="include_position_filename" value="false"/>
           <process expanded="true">
             <operator activated="true" class="imageprocessing:color_model_operator" compatibility="1.4.001" expanded="true" height="60" name="ClrToGS(Hue)" width="90" x="45" y="30">
               <parameter key="Color component" value="Hue"/>
             </operator>
             <operator activated="true" class="imageprocessing:grayscale_to_color" compatibility="1.4.001" expanded="true" height="60" name="Grayscale to color" width="90" x="246" y="75"/>
             <operator activated="true" class="imageprocessing:color_model_operator" compatibility="1.4.001" expanded="true" height="60" name="ClrToGS (Saturation)" width="90" x="45" y="120">
               <parameter key="Color component" value="Saturation"/>
             </operator>
             <operator activated="true" class="imageprocessing:color_model_operator" compatibility="1.4.001" expanded="true" height="60" name="ClrToGS (Value)" width="90" x="45" y="210">
               <parameter key="Color component" value="Value"/>
             </operator>
             <operator activated="true" class="imageprocessing:grayscale_to_color" compatibility="1.4.001" expanded="true" height="60" name="Grayscale to color (2)" width="90" x="246" y="255"/>
             <operator activated="true" class="imageprocessing:grayscale_to_color" compatibility="1.4.001" expanded="true" height="60" name="Grayscale to color (3)" width="90" x="246" y="165"/>
             <operator activated="true" class="imageprocessing:histogram" compatibility="1.4.001" expanded="true" height="60" name="histogram(H)" width="90" x="447" y="75"/>
             <operator activated="true" class="imageprocessing:histogram" compatibility="1.4.001" expanded="true" height="60" name="histogram (S)" width="90" x="447" y="165"/>
             <operator activated="true" class="imageprocessing:histogram" compatibility="1.4.001" expanded="true" height="60" name="histogram (V)" width="90" x="447" y="255"/>
             <connect from_port="color image plus 1" to_op="ClrToGS(Hue)" to_port="color image plus"/>
             <connect from_port="color image plus 2" to_op="ClrToGS (Saturation)" to_port="color image plus"/>
             <connect from_port="color image plus 3" to_op="ClrToGS (Value)" to_port="color image plus"/>
             <connect from_op="ClrToGS(Hue)" from_port="grayscale image plus" to_op="Grayscale to color" to_port="grayscale image plus"/>
             <connect from_op="Grayscale to color" from_port="color image" to_op="histogram(H)" to_port="color image plus"/>
             <connect from_op="ClrToGS (Saturation)" from_port="grayscale image plus" to_op="Grayscale to color (3)" to_port="grayscale image plus"/>
             <connect from_op="ClrToGS (Value)" from_port="grayscale image plus" to_op="Grayscale to color (2)" to_port="grayscale image plus"/>
             <connect from_op="Grayscale to color (2)" from_port="color image" to_op="histogram (V)" to_port="color image plus"/>
             <connect from_op="Grayscale to color (3)" from_port="color image" to_op="histogram (S)" to_port="color image plus"/>
             <connect from_op="histogram(H)" from_port="features" to_port="feature 1"/>
             <connect from_op="histogram (S)" from_port="features" to_port="feature 2"/>
             <connect from_op="histogram (V)" from_port="features" to_port="feature 3"/>
             <portSpacing port="source_color image plus 1" spacing="0"/>
             <portSpacing port="source_color image plus 2" spacing="0"/>
             <portSpacing port="source_color image plus 3" spacing="0"/>
             <portSpacing port="source_color image plus 4" spacing="0"/>
             <portSpacing port="sink_feature 1" spacing="0"/>
             <portSpacing port="sink_feature 2" spacing="0"/>
             <portSpacing port="sink_feature 3" spacing="0"/>
             <portSpacing port="sink_feature 4" 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>
     <connect from_op="MCIO(H)" from_port="example set" 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>
7 REPLIES
Regular Contributor

Re: Image Mining: Color Histogram

Hello elag,
you can combine HSV channels to one image and then create histogram:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.005">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="5.3.005" expanded="true" name="Process">
    <parameter key="logfile" value="C:\Users\Elena\Dropbox\Master\Thesis\RapidMiner\logfile\log.txt"/>
    <parameter key="resultfile" value="C:\Users\Elena\Dropbox\Master\Thesis\RapidMiner\resultfile\resultfile.txt"/>
    <process expanded="true">
      <operator activated="true" class="imageprocessing:multiple_color_image_opener" compatibility="1.4.001" expanded="true" height="60" name="MCIO(H)" width="90" x="45" y="30">
        <list key="images">
          <parameter key="city" value="C:\Users\Elena\Dropbox\Master\Thesis\mcio"/>
        </list>
        <parameter key="auto_adjust_contrast" value="true"/>
        <process expanded="true">
          <operator activated="true" class="imageprocessing:global_feature_extraction" compatibility="1.4.001" expanded="true" height="60" name="Global Feature Extractor from a Single Image" width="90" x="246" y="75">
            <parameter key="include_position_filename" value="false"/>
            <process expanded="true">
              <operator activated="true" class="imageprocessing:color_model_operator" compatibility="1.4.001" expanded="true" height="60" name="ClrToGS(Hue)" width="90" x="45" y="30">
                <parameter key="Color component" value="Hue"/>
              </operator>
              <operator activated="true" class="imageprocessing:color_model_operator" compatibility="1.4.001" expanded="true" height="60" name="ClrToGS (Saturation)" width="90" x="45" y="120">
                <parameter key="Color component" value="Saturation"/>
              </operator>
              <operator activated="true" class="imageprocessing:color_model_operator" compatibility="1.4.001" expanded="true" height="60" name="ClrToGS (Value)" width="90" x="45" y="210">
                <parameter key="Color component" value="Value"/>
              </operator>
              <operator activated="true" class="imageprocessing:create_color_image" compatibility="1.4.001" expanded="true" height="94" name="Create Color Image" width="90" x="246" y="75"/>
              <operator activated="true" class="imageprocessing:histogram" compatibility="1.4.001" expanded="true" height="60" name="histogram(H)" width="90" x="447" y="75"/>
              <connect from_port="color image plus 1" to_op="ClrToGS(Hue)" to_port="color image plus"/>
              <connect from_port="color image plus 2" to_op="ClrToGS (Saturation)" to_port="color image plus"/>
              <connect from_port="color image plus 3" to_op="ClrToGS (Value)" to_port="color image plus"/>
              <connect from_op="ClrToGS(Hue)" from_port="grayscale image plus" to_op="Create Color Image" to_port="grayscale image plus X"/>
              <connect from_op="ClrToGS (Saturation)" from_port="grayscale image plus" to_op="Create Color Image" to_port="grayscale image plus Y"/>
              <connect from_op="ClrToGS (Value)" from_port="grayscale image plus" to_op="Create Color Image" to_port="grayscale image plus Z"/>
              <connect from_op="Create Color Image" from_port="color image plus" to_op="histogram(H)" to_port="color image plus"/>
              <connect from_op="histogram(H)" 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="source_color image plus 3" spacing="0"/>
              <portSpacing port="source_color image plus 4" 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>
      <connect from_op="MCIO(H)" from_port="example set" 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>


Best,
Vaclav

Re: Image Mining: Color Histogram

Hello StaryVena,

thank you for the reply and I am sorry for my delay to reply. It is just that I am trying to understand what information do I get. With your workflow but also when I try to extract H,S or V separately the result that I get is 0.001 at histogram62 and 0.999 at histogram63(0..000  and 1.000 when I do only H,S or V).
-Does then number of bins even plays a role here?
-Why is the result displayed at  histogram62 and  histogram63 and not in another one?
-And finally what does this information tells me about the particular image? If e.g. I extract histograms only for Value and I get 1.000 at histogram63, does this mean that my image is very bright? But for which Hue?

I know that these are understanding questions, but although I understand HSV model I don't understand the information that RapidMiner give me here.


I hope this was not too much.

Best,
elag
Regular Contributor

Re: Image Mining: Color Histogram

Hello elag,
Does then number of bins even plays a role here?

I don't know image do you have, so it is hard to say.
Why is the result displayed at  histogram62 and  histogram63 and not in another one?

Maybe you have image with only two colors or only similar colors in small range. Try to set histogram bins to 128.
And finally what does this information tells me about the particular image? If e.g. I extract histograms only for Value and I get 1.000 at histogram63, does this mean that my image is very bright? But for which Hue?

Image is converted to gray scale before histogram is calculated. So in color image it is hard to say. But if you have only hue channel it is the max value of hue.

If you explain what you want to do, maybe I can help you more.

Best,
Vaclav

Re: Image Mining: Color Histogram

Hello Vaclav,

thanks for the reply.

What I want to do is extract HSV color histograms. My test photo has more than 2 colors and even when I try to extract only one of the HSV channel Iend up having values only on histogram 62, 63. This is either wrong or I don't understand what should the HSV result be.

Best,
Elena
Regular Contributor

Re: Image Mining: Color Histogram

Hello Elena,
can you post example image? I will try it.

Best,
Vaclav

Re: Image Mining: Color Histogram

Hi  Vaclav,

i sent you a pm with the image.

Thank you very much,
Elena

Re: [SOLVED] Image Mining: Color Histogram

Problem Solved.

The workflow provided above from Vaclav was correct. There was a bug in my  version of the image extension.