Batch color thresholder

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Batch color thresholder

ram prasad
Hi all,

I would like to quantify yellow colour intensity on a number of images, but
I am having trouble writing a macro for that purpose.

I can get as far as opening the colour thresholder and applying my
cut-off's but then selecting the region of interest is a bit slippery and
I'm hoping you guys can help me out with this.

This is what I'd intended to do.

1) Create a duplicate of my image  (Image -> Duplicate)
2) Open the thresholder and select yellow pixels using the hue slider
(Image -> Adjust -> Threshold)
3) Then create a selection (Edit -> Selection -> Create selection)
4) Restore the selection on the original image (Edit -> Select -> Restore
selection)
5) Finally, measure Integrated density using (Analyze -> Measure)

The problem I have with the third step is that when I try to create a
selection (using Edit -> Selection -> Create Selection) I get a pop-up with
the following message,

"This command creates a composite selection from a mask or from an image
that has been thresholded using Image -> Adjust ->Threshold tool. The
current image is not a mask and has not been thresholded"

I'm not sure why I'm getting this error here as I used Image -> Adjust
->Threshold to threshold my image.

I'm attaching a sample image here for your reference. Please let me know if
you need more information from my side.

P.S the click operation on the Select button in the thresholder dialog box
does not get recorded in the macro recorder that's why I'm resorting to
Edit -> Select -> Create selection to create a selection.

Thanks,
R

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

ed_206-100-1.jpg (894K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Batch color thresholder

Olivier Burri
Hi,

If you select "Macro" from the Threshold Color window, it will give you a macro code you can run and get a mask that you can use "Create Selection" on

However the question remains on what you are trying to measure on your original RGB image. From what I gather if you measure inside a selection, you will get the average of the red green and blue channels where you want the 'yellow color intensity' which is not really that.

I'd like others' opinions on this, but a better approach once you have your mask is to measure the Brightness component of your original image converted to HSB stack (Slice 3).

Best

Oli


> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> ram prasad
> Sent: Tuesday, September 1, 2015 16:08
> To: [hidden email]
> Subject: Batch color thresholder
>
> Hi all,
>
> I would like to quantify yellow colour intensity on a number of images, but I
> am having trouble writing a macro for that purpose.
>
> I can get as far as opening the colour thresholder and applying my cut-off's
> but then selecting the region of interest is a bit slippery and I'm hoping you
> guys can help me out with this.
>
> This is what I'd intended to do.
>
> 1) Create a duplicate of my image  (Image -> Duplicate)
> 2) Open the thresholder and select yellow pixels using the hue slider (Image -
> > Adjust -> Threshold)
> 3) Then create a selection (Edit -> Selection -> Create selection)
> 4) Restore the selection on the original image (Edit -> Select -> Restore
> selection)
> 5) Finally, measure Integrated density using (Analyze -> Measure)
>
> The problem I have with the third step is that when I try to create a selection
> (using Edit -> Selection -> Create Selection) I get a pop-up with the following
> message,
>
> "This command creates a composite selection from a mask or from an image
> that has been thresholded using Image -> Adjust ->Threshold tool. The
> current image is not a mask and has not been thresholded"
>
> I'm not sure why I'm getting this error here as I used Image -> Adjust
> ->Threshold to threshold my image.
>
> I'm attaching a sample image here for your reference. Please let me know if
> you need more information from my side.
>
> P.S the click operation on the Select button in the thresholder dialog box
> does not get recorded in the macro recorder that's why I'm resorting to Edit -
> > Select -> Create selection to create a selection.
>
> Thanks,
> R
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Batch color thresholder

ram prasad
Hi Oli,

Thank you very much for your response.

When I select "Macro" from the threshold color, it gives me a macro code
and a red coloured mask on the area of my interest. However, when I try to
create a selection on this mask I get the error I mentioned in the first
mail in this thread.

"However the question remains on what you are trying to measure on your
original RGB image. From what I gather if you measure inside a selection,
you will get the average of the red green and blue channels where you want
the 'yellow color intensity' which is not really that."

I was under the impression that selecting yellow pixels with the hue slider
should give me a selection that has only yellow pixels. That way when I
measure saturation I should get the intensity only for the yellow pixels?
I'd like your opinion on this one.

Herewith, I have attached two images that show a difference in the
intensity (one is yellow and the other one is pale), for your reference.
This difference is what I would like to measure.

Best,
R


On Tue, Sep 1, 2015 at 5:12 PM, Burri Olivier <[hidden email]> wrote:

> Hi,
>
> If you select "Macro" from the Threshold Color window, it will give you a
> macro code you can run and get a mask that you can use "Create Selection" on
>
> However the question remains on what you are trying to measure on your
> original RGB image. From what I gather if you measure inside a selection,
> you will get the average of the red green and blue channels where you want
> the 'yellow color intensity' which is not really that.
>
> I'd like others' opinions on this, but a better approach once you have
> your mask is to measure the Brightness component of your original image
> converted to HSB stack (Slice 3).
>
> Best
>
> Oli
>
>
> > -----Original Message-----
> > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> > ram prasad
> > Sent: Tuesday, September 1, 2015 16:08
> > To: [hidden email]
> > Subject: Batch color thresholder
> >
> > Hi all,
> >
> > I would like to quantify yellow colour intensity on a number of images,
> but I
> > am having trouble writing a macro for that purpose.
> >
> > I can get as far as opening the colour thresholder and applying my
> cut-off's
> > but then selecting the region of interest is a bit slippery and I'm
> hoping you
> > guys can help me out with this.
> >
> > This is what I'd intended to do.
> >
> > 1) Create a duplicate of my image  (Image -> Duplicate)
> > 2) Open the thresholder and select yellow pixels using the hue slider
> (Image -
> > > Adjust -> Threshold)
> > 3) Then create a selection (Edit -> Selection -> Create selection)
> > 4) Restore the selection on the original image (Edit -> Select -> Restore
> > selection)
> > 5) Finally, measure Integrated density using (Analyze -> Measure)
> >
> > The problem I have with the third step is that when I try to create a
> selection
> > (using Edit -> Selection -> Create Selection) I get a pop-up with the
> following
> > message,
> >
> > "This command creates a composite selection from a mask or from an image
> > that has been thresholded using Image -> Adjust ->Threshold tool. The
> > current image is not a mask and has not been thresholded"
> >
> > I'm not sure why I'm getting this error here as I used Image -> Adjust
> > ->Threshold to threshold my image.
> >
> > I'm attaching a sample image here for your reference. Please let me know
> if
> > you need more information from my side.
> >
> > P.S the click operation on the Select button in the thresholder dialog
> box
> > does not get recorded in the macro recorder that's why I'm resorting to
> Edit -
> > > Select -> Create selection to create a selection.
> >
> > Thanks,
> > R
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Batch color thresholder

Olivier Burri
Hi Ram,

Your images were not attached, by the way.

Selecting "macro" creates the macro code, but you still need to run it separately to obtain the desired mask.

As you say, saturation will give you an idea as to how 'pure' your yellow is, which is a good indication if you are going towards 'pale' as you say. But I cannot say without an image to look at. The risk I see is that is less saturated images, you might not be able to pick up your hue as well, decreasing the number of pixels for the saturation measurement. Perhaps using the 'brightness image' to select only the parts of the wing with bright elements and then measuring the saturation regardless or hue could work? I suggest you try both manually and see if you get the same result?
Again I'd be happy to have other's opinion on this.

Ideally if you want to go through this quantitative route, you need some sort of internal control for the intensity/colors. Usually people use a color palette taken in conjunction with the image so that in case the white balance changes or overall illumination is modified, these can be corrected before proceeding with quantification. Something like this: http://scientific.datacolor.com/products/macro-calibration-target/

Finally, if you have tried transforming your RGB image to HSB (Image->Type->HSB Stack), you will have noticed some nasty artifacts, especially in the saturation image. This is the problem with
1. JPEG compression creating artifacts due to the nature of the compression algorithm.

2. Potential oversaturation of the image by the camera to make the image more 'appealing'. This often happens unbeknownst to the user.

So please always work in RAW formats to avoid these kinds of issues. You will most likely get a significant difference in your metric, as it is probably clear cut, but the data quality could be deemed insufficient because of the JPEG compression. So it is at your own risk.

Best

Oli



> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> ram prasad
> Sent: Wednesday, September 2, 2015 10:42
> To: [hidden email]
> Subject: Re: Batch color thresholder
>
> Hi Oli,
>
> Thank you very much for your response.
>
> When I select "Macro" from the threshold color, it gives me a macro code
> and a red coloured mask on the area of my interest. However, when I try to
> create a selection on this mask I get the error I mentioned in the first mail in
> this thread.
>
> "However the question remains on what you are trying to measure on your
> original RGB image. From what I gather if you measure inside a selection, you
> will get the average of the red green and blue channels where you want the
> 'yellow color intensity' which is not really that."
>
> I was under the impression that selecting yellow pixels with the hue slider
> should give me a selection that has only yellow pixels. That way when I
> measure saturation I should get the intensity only for the yellow pixels?
> I'd like your opinion on this one.
>
> Herewith, I have attached two images that show a difference in the intensity
> (one is yellow and the other one is pale), for your reference.
> This difference is what I would like to measure.
>
> Best,
> R
>
>
> On Tue, Sep 1, 2015 at 5:12 PM, Burri Olivier <[hidden email]> wrote:
>
> > Hi,
> >
> > If you select "Macro" from the Threshold Color window, it will give
> > you a macro code you can run and get a mask that you can use "Create
> > Selection" on
> >
> > However the question remains on what you are trying to measure on your
> > original RGB image. From what I gather if you measure inside a
> > selection, you will get the average of the red green and blue channels
> > where you want the 'yellow color intensity' which is not really that.
> >
> > I'd like others' opinions on this, but a better approach once you have
> > your mask is to measure the Brightness component of your original
> > image converted to HSB stack (Slice 3).
> >
> > Best
> >
> > Oli
> >
> >
> > > -----Original Message-----
> > > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf
> > > Of ram prasad
> > > Sent: Tuesday, September 1, 2015 16:08
> > > To: [hidden email]
> > > Subject: Batch color thresholder
> > >
> > > Hi all,
> > >
> > > I would like to quantify yellow colour intensity on a number of
> > > images,
> > but I
> > > am having trouble writing a macro for that purpose.
> > >
> > > I can get as far as opening the colour thresholder and applying my
> > cut-off's
> > > but then selecting the region of interest is a bit slippery and I'm
> > hoping you
> > > guys can help me out with this.
> > >
> > > This is what I'd intended to do.
> > >
> > > 1) Create a duplicate of my image  (Image -> Duplicate)
> > > 2) Open the thresholder and select yellow pixels using the hue
> > > slider
> > (Image -
> > > > Adjust -> Threshold)
> > > 3) Then create a selection (Edit -> Selection -> Create selection)
> > > 4) Restore the selection on the original image (Edit -> Select ->
> > > Restore
> > > selection)
> > > 5) Finally, measure Integrated density using (Analyze -> Measure)
> > >
> > > The problem I have with the third step is that when I try to create
> > > a
> > selection
> > > (using Edit -> Selection -> Create Selection) I get a pop-up with
> > > the
> > following
> > > message,
> > >
> > > "This command creates a composite selection from a mask or from an
> > > image that has been thresholded using Image -> Adjust ->Threshold
> > > tool. The current image is not a mask and has not been thresholded"
> > >
> > > I'm not sure why I'm getting this error here as I used Image ->
> > > Adjust
> > > ->Threshold to threshold my image.
> > >
> > > I'm attaching a sample image here for your reference. Please let me
> > > know
> > if
> > > you need more information from my side.
> > >
> > > P.S the click operation on the Select button in the thresholder
> > > dialog
> > box
> > > does not get recorded in the macro recorder that's why I'm resorting
> > > to
> > Edit -
> > > > Select -> Create selection to create a selection.
> > >
> > > Thanks,
> > > R
> > >
> > > --
> > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Batch color thresholder

ram prasad
Hi Oli,

I'm not sure why the images were not attached because I can see it in my
original email to the group. Anyway, herewith I'm attaching the images
again.

I have only three colours in my image -blue,yellow and black- and blue and
black are a bit far apart in the hue scale. So, I think I can be a bit
relaxed with my hue settings and this should take care of that potential
risk arising from less saturated images don't you think?

Also, I haven't had any luck with obtaining the desired selection and I'm
not sure where I am going wrong. Would you be kind enough to write me a
macro so that I can see what I'm doing wrong? That would be very helpful.

Thank you very much.

Best,
Ram

On Wed, Sep 2, 2015 at 11:32 AM, Burri Olivier <[hidden email]>
wrote:

> Hi Ram,
>
> Your images were not attached, by the way.
>
> Selecting "macro" creates the macro code, but you still need to run it
> separately to obtain the desired mask.
>
> As you say, saturation will give you an idea as to how 'pure' your yellow
> is, which is a good indication if you are going towards 'pale' as you say.
> But I cannot say without an image to look at. The risk I see is that is
> less saturated images, you might not be able to pick up your hue as well,
> decreasing the number of pixels for the saturation measurement. Perhaps
> using the 'brightness image' to select only the parts of the wing with
> bright elements and then measuring the saturation regardless or hue could
> work? I suggest you try both manually and see if you get the same result?
> Again I'd be happy to have other's opinion on this.
>
> Ideally if you want to go through this quantitative route, you need some
> sort of internal control for the intensity/colors. Usually people use a
> color palette taken in conjunction with the image so that in case the white
> balance changes or overall illumination is modified, these can be corrected
> before proceeding with quantification. Something like this:
> http://scientific.datacolor.com/products/macro-calibration-target/
>
> Finally, if you have tried transforming your RGB image to HSB
> (Image->Type->HSB Stack), you will have noticed some nasty artifacts,
> especially in the saturation image. This is the problem with
> 1. JPEG compression creating artifacts due to the nature of the
> compression algorithm.
>
> 2. Potential oversaturation of the image by the camera to make the image
> more 'appealing'. This often happens unbeknownst to the user.
>
> So please always work in RAW formats to avoid these kinds of issues. You
> will most likely get a significant difference in your metric, as it is
> probably clear cut, but the data quality could be deemed insufficient
> because of the JPEG compression. So it is at your own risk.
>
> Best
>
> Oli
>
>
>
> > -----Original Message-----
> > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> > ram prasad
> > Sent: Wednesday, September 2, 2015 10:42
> > To: [hidden email]
> > Subject: Re: Batch color thresholder
> >
> > Hi Oli,
> >
> > Thank you very much for your response.
> >
> > When I select "Macro" from the threshold color, it gives me a macro code
> > and a red coloured mask on the area of my interest. However, when I try
> to
> > create a selection on this mask I get the error I mentioned in the first
> mail in
> > this thread.
> >
> > "However the question remains on what you are trying to measure on your
> > original RGB image. From what I gather if you measure inside a
> selection, you
> > will get the average of the red green and blue channels where you want
> the
> > 'yellow color intensity' which is not really that."
> >
> > I was under the impression that selecting yellow pixels with the hue
> slider
> > should give me a selection that has only yellow pixels. That way when I
> > measure saturation I should get the intensity only for the yellow pixels?
> > I'd like your opinion on this one.
> >
> > Herewith, I have attached two images that show a difference in the
> intensity
> > (one is yellow and the other one is pale), for your reference.
> > This difference is what I would like to measure.
> >
> > Best,
> > R
> >
> >
> > On Tue, Sep 1, 2015 at 5:12 PM, Burri Olivier <[hidden email]>
> wrote:
> >
> > > Hi,
> > >
> > > If you select "Macro" from the Threshold Color window, it will give
> > > you a macro code you can run and get a mask that you can use "Create
> > > Selection" on
> > >
> > > However the question remains on what you are trying to measure on your
> > > original RGB image. From what I gather if you measure inside a
> > > selection, you will get the average of the red green and blue channels
> > > where you want the 'yellow color intensity' which is not really that.
> > >
> > > I'd like others' opinions on this, but a better approach once you have
> > > your mask is to measure the Brightness component of your original
> > > image converted to HSB stack (Slice 3).
> > >
> > > Best
> > >
> > > Oli
> > >
> > >
> > > > -----Original Message-----
> > > > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf
> > > > Of ram prasad
> > > > Sent: Tuesday, September 1, 2015 16:08
> > > > To: [hidden email]
> > > > Subject: Batch color thresholder
> > > >
> > > > Hi all,
> > > >
> > > > I would like to quantify yellow colour intensity on a number of
> > > > images,
> > > but I
> > > > am having trouble writing a macro for that purpose.
> > > >
> > > > I can get as far as opening the colour thresholder and applying my
> > > cut-off's
> > > > but then selecting the region of interest is a bit slippery and I'm
> > > hoping you
> > > > guys can help me out with this.
> > > >
> > > > This is what I'd intended to do.
> > > >
> > > > 1) Create a duplicate of my image  (Image -> Duplicate)
> > > > 2) Open the thresholder and select yellow pixels using the hue
> > > > slider
> > > (Image -
> > > > > Adjust -> Threshold)
> > > > 3) Then create a selection (Edit -> Selection -> Create selection)
> > > > 4) Restore the selection on the original image (Edit -> Select ->
> > > > Restore
> > > > selection)
> > > > 5) Finally, measure Integrated density using (Analyze -> Measure)
> > > >
> > > > The problem I have with the third step is that when I try to create
> > > > a
> > > selection
> > > > (using Edit -> Selection -> Create Selection) I get a pop-up with
> > > > the
> > > following
> > > > message,
> > > >
> > > > "This command creates a composite selection from a mask or from an
> > > > image that has been thresholded using Image -> Adjust ->Threshold
> > > > tool. The current image is not a mask and has not been thresholded"
> > > >
> > > > I'm not sure why I'm getting this error here as I used Image ->
> > > > Adjust
> > > > ->Threshold to threshold my image.
> > > >
> > > > I'm attaching a sample image here for your reference. Please let me
> > > > know
> > > if
> > > > you need more information from my side.
> > > >
> > > > P.S the click operation on the Select button in the thresholder
> > > > dialog
> > > box
> > > > does not get recorded in the macro recorder that's why I'm resorting
> > > > to
> > > Edit -
> > > > > Select -> Create selection to create a selection.
> > > >
> > > > Thanks,
> > > > R
> > > >
> > > > --
> > > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> > >
> > > --
> > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> > >
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Batch color thresholder

Olivier Burri
Hi again,

Seems the list will not attach more images? Maybe provide them via dropbox or some other similar service.

Here is an example macro.

https://gist.github.com/lacan/05a8f7ab507560e51a1c

I just copy pasted the macro code and added the lines 1-3 and 47-52

Just have one of your images open and run it.

Best

Oli



> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> ram prasad
> Sent: Wednesday, September 2, 2015 12:47
> To: [hidden email]
> Subject: Re: Batch color thresholder
>
> Hi Oli,
>
> I'm not sure why the images were not attached because I can see it in my
> original email to the group. Anyway, herewith I'm attaching the images again.
>
> I have only three colours in my image -blue,yellow and black- and blue and
> black are a bit far apart in the hue scale. So, I think I can be a bit relaxed with
> my hue settings and this should take care of that potential risk arising from
> less saturated images don't you think?
>
> Also, I haven't had any luck with obtaining the desired selection and I'm not
> sure where I am going wrong. Would you be kind enough to write me a
> macro so that I can see what I'm doing wrong? That would be very helpful.
>
> Thank you very much.
>
> Best,
> Ram
>
> On Wed, Sep 2, 2015 at 11:32 AM, Burri Olivier <[hidden email]>
> wrote:
>
> > Hi Ram,
> >
> > Your images were not attached, by the way.
> >
> > Selecting "macro" creates the macro code, but you still need to run it
> > separately to obtain the desired mask.
> >
> > As you say, saturation will give you an idea as to how 'pure' your
> > yellow is, which is a good indication if you are going towards 'pale' as you
> say.
> > But I cannot say without an image to look at. The risk I see is that
> > is less saturated images, you might not be able to pick up your hue as
> > well, decreasing the number of pixels for the saturation measurement.
> > Perhaps using the 'brightness image' to select only the parts of the
> > wing with bright elements and then measuring the saturation regardless
> > or hue could work? I suggest you try both manually and see if you get the
> same result?
> > Again I'd be happy to have other's opinion on this.
> >
> > Ideally if you want to go through this quantitative route, you need
> > some sort of internal control for the intensity/colors. Usually people
> > use a color palette taken in conjunction with the image so that in
> > case the white balance changes or overall illumination is modified,
> > these can be corrected before proceeding with quantification. Something
> like this:
> > http://scientific.datacolor.com/products/macro-calibration-target/
> >
> > Finally, if you have tried transforming your RGB image to HSB
> > (Image->Type->HSB Stack), you will have noticed some nasty artifacts,
> > especially in the saturation image. This is the problem with 1. JPEG
> > compression creating artifacts due to the nature of the compression
> > algorithm.
> >
> > 2. Potential oversaturation of the image by the camera to make the
> > image more 'appealing'. This often happens unbeknownst to the user.
> >
> > So please always work in RAW formats to avoid these kinds of issues.
> > You will most likely get a significant difference in your metric, as
> > it is probably clear cut, but the data quality could be deemed
> > insufficient because of the JPEG compression. So it is at your own risk.
> >
> > Best
> >
> > Oli
> >
> >
> >
> > > -----Original Message-----
> > > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf
> > > Of ram prasad
> > > Sent: Wednesday, September 2, 2015 10:42
> > > To: [hidden email]
> > > Subject: Re: Batch color thresholder
> > >
> > > Hi Oli,
> > >
> > > Thank you very much for your response.
> > >
> > > When I select "Macro" from the threshold color, it gives me a macro
> > > code and a red coloured mask on the area of my interest. However,
> > > when I try
> > to
> > > create a selection on this mask I get the error I mentioned in the
> > > first
> > mail in
> > > this thread.
> > >
> > > "However the question remains on what you are trying to measure on
> > > your original RGB image. From what I gather if you measure inside a
> > selection, you
> > > will get the average of the red green and blue channels where you
> > > want
> > the
> > > 'yellow color intensity' which is not really that."
> > >
> > > I was under the impression that selecting yellow pixels with the hue
> > slider
> > > should give me a selection that has only yellow pixels. That way
> > > when I measure saturation I should get the intensity only for the yellow
> pixels?
> > > I'd like your opinion on this one.
> > >
> > > Herewith, I have attached two images that show a difference in the
> > intensity
> > > (one is yellow and the other one is pale), for your reference.
> > > This difference is what I would like to measure.
> > >
> > > Best,
> > > R
> > >
> > >
> > > On Tue, Sep 1, 2015 at 5:12 PM, Burri Olivier
> > > <[hidden email]>
> > wrote:
> > >
> > > > Hi,
> > > >
> > > > If you select "Macro" from the Threshold Color window, it will
> > > > give you a macro code you can run and get a mask that you can use
> > > > "Create Selection" on
> > > >
> > > > However the question remains on what you are trying to measure on
> > > > your original RGB image. From what I gather if you measure inside
> > > > a selection, you will get the average of the red green and blue
> > > > channels where you want the 'yellow color intensity' which is not really
> that.
> > > >
> > > > I'd like others' opinions on this, but a better approach once you
> > > > have your mask is to measure the Brightness component of your
> > > > original image converted to HSB stack (Slice 3).
> > > >
> > > > Best
> > > >
> > > > Oli
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: ImageJ Interest Group [mailto:[hidden email]] On
> > > > > Behalf Of ram prasad
> > > > > Sent: Tuesday, September 1, 2015 16:08
> > > > > To: [hidden email]
> > > > > Subject: Batch color thresholder
> > > > >
> > > > > Hi all,
> > > > >
> > > > > I would like to quantify yellow colour intensity on a number of
> > > > > images,
> > > > but I
> > > > > am having trouble writing a macro for that purpose.
> > > > >
> > > > > I can get as far as opening the colour thresholder and applying
> > > > > my
> > > > cut-off's
> > > > > but then selecting the region of interest is a bit slippery and
> > > > > I'm
> > > > hoping you
> > > > > guys can help me out with this.
> > > > >
> > > > > This is what I'd intended to do.
> > > > >
> > > > > 1) Create a duplicate of my image  (Image -> Duplicate)
> > > > > 2) Open the thresholder and select yellow pixels using the hue
> > > > > slider
> > > > (Image -
> > > > > > Adjust -> Threshold)
> > > > > 3) Then create a selection (Edit -> Selection -> Create
> > > > > selection)
> > > > > 4) Restore the selection on the original image (Edit -> Select
> > > > > -> Restore
> > > > > selection)
> > > > > 5) Finally, measure Integrated density using (Analyze ->
> > > > > Measure)
> > > > >
> > > > > The problem I have with the third step is that when I try to
> > > > > create a
> > > > selection
> > > > > (using Edit -> Selection -> Create Selection) I get a pop-up
> > > > > with the
> > > > following
> > > > > message,
> > > > >
> > > > > "This command creates a composite selection from a mask or from
> > > > > an image that has been thresholded using Image -> Adjust
> > > > > ->Threshold tool. The current image is not a mask and has not been
> thresholded"
> > > > >
> > > > > I'm not sure why I'm getting this error here as I used Image ->
> > > > > Adjust
> > > > > ->Threshold to threshold my image.
> > > > >
> > > > > I'm attaching a sample image here for your reference. Please let
> > > > > me know
> > > > if
> > > > > you need more information from my side.
> > > > >
> > > > > P.S the click operation on the Select button in the thresholder
> > > > > dialog
> > > > box
> > > > > does not get recorded in the macro recorder that's why I'm
> > > > > resorting to
> > > > Edit -
> > > > > > Select -> Create selection to create a selection.
> > > > >
> > > > > Thanks,
> > > > > R
> > > > >
> > > > > --
> > > > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> > > >
> > > > --
> > > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> > > >
> > >
> > > --
> > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Batch color thresholder

ram prasad
Hi again,

Apologies for my delayed response. Here is a dropbox link to the images,
https://www.dropbox.com/sh/l0p0qb4h3fq2emx/AAAHIelRJI7gk2udVE5-WLJFa?dl=0

The macro code worked!! Thank you very much. I find this very surprising
because it looks identical to mine, but I did not run get as far as to
running mine in batch. I kept getting that error and I didn't even bother
using it for batch processing. So, all this time I was one foot away from
the gold.

Please have a look at the images and let me know what you think. Thanks
again.

Ram

On Wed, Sep 2, 2015 at 12:57 PM, Burri Olivier <[hidden email]>
wrote:

> Hi again,
>
> Seems the list will not attach more images? Maybe provide them via dropbox
> or some other similar service.
>
> Here is an example macro.
>
> https://gist.github.com/lacan/05a8f7ab507560e51a1c
>
> I just copy pasted the macro code and added the lines 1-3 and 47-52
>
> Just have one of your images open and run it.
>
> Best
>
> Oli
>
>
>
> > -----Original Message-----
> > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> > ram prasad
> > Sent: Wednesday, September 2, 2015 12:47
> > To: [hidden email]
> > Subject: Re: Batch color thresholder
> >
> > Hi Oli,
> >
> > I'm not sure why the images were not attached because I can see it in my
> > original email to the group. Anyway, herewith I'm attaching the images
> again.
> >
> > I have only three colours in my image -blue,yellow and black- and blue
> and
> > black are a bit far apart in the hue scale. So, I think I can be a bit
> relaxed with
> > my hue settings and this should take care of that potential risk arising
> from
> > less saturated images don't you think?
> >
> > Also, I haven't had any luck with obtaining the desired selection and
> I'm not
> > sure where I am going wrong. Would you be kind enough to write me a
> > macro so that I can see what I'm doing wrong? That would be very helpful.
> >
> > Thank you very much.
> >
> > Best,
> > Ram
> >
> > On Wed, Sep 2, 2015 at 11:32 AM, Burri Olivier <[hidden email]>
> > wrote:
> >
> > > Hi Ram,
> > >
> > > Your images were not attached, by the way.
> > >
> > > Selecting "macro" creates the macro code, but you still need to run it
> > > separately to obtain the desired mask.
> > >
> > > As you say, saturation will give you an idea as to how 'pure' your
> > > yellow is, which is a good indication if you are going towards 'pale'
> as you
> > say.
> > > But I cannot say without an image to look at. The risk I see is that
> > > is less saturated images, you might not be able to pick up your hue as
> > > well, decreasing the number of pixels for the saturation measurement.
> > > Perhaps using the 'brightness image' to select only the parts of the
> > > wing with bright elements and then measuring the saturation regardless
> > > or hue could work? I suggest you try both manually and see if you get
> the
> > same result?
> > > Again I'd be happy to have other's opinion on this.
> > >
> > > Ideally if you want to go through this quantitative route, you need
> > > some sort of internal control for the intensity/colors. Usually people
> > > use a color palette taken in conjunction with the image so that in
> > > case the white balance changes or overall illumination is modified,
> > > these can be corrected before proceeding with quantification. Something
> > like this:
> > > http://scientific.datacolor.com/products/macro-calibration-target/
> > >
> > > Finally, if you have tried transforming your RGB image to HSB
> > > (Image->Type->HSB Stack), you will have noticed some nasty artifacts,
> > > especially in the saturation image. This is the problem with 1. JPEG
> > > compression creating artifacts due to the nature of the compression
> > > algorithm.
> > >
> > > 2. Potential oversaturation of the image by the camera to make the
> > > image more 'appealing'. This often happens unbeknownst to the user.
> > >
> > > So please always work in RAW formats to avoid these kinds of issues.
> > > You will most likely get a significant difference in your metric, as
> > > it is probably clear cut, but the data quality could be deemed
> > > insufficient because of the JPEG compression. So it is at your own
> risk.
> > >
> > > Best
> > >
> > > Oli
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf
> > > > Of ram prasad
> > > > Sent: Wednesday, September 2, 2015 10:42
> > > > To: [hidden email]
> > > > Subject: Re: Batch color thresholder
> > > >
> > > > Hi Oli,
> > > >
> > > > Thank you very much for your response.
> > > >
> > > > When I select "Macro" from the threshold color, it gives me a macro
> > > > code and a red coloured mask on the area of my interest. However,
> > > > when I try
> > > to
> > > > create a selection on this mask I get the error I mentioned in the
> > > > first
> > > mail in
> > > > this thread.
> > > >
> > > > "However the question remains on what you are trying to measure on
> > > > your original RGB image. From what I gather if you measure inside a
> > > selection, you
> > > > will get the average of the red green and blue channels where you
> > > > want
> > > the
> > > > 'yellow color intensity' which is not really that."
> > > >
> > > > I was under the impression that selecting yellow pixels with the hue
> > > slider
> > > > should give me a selection that has only yellow pixels. That way
> > > > when I measure saturation I should get the intensity only for the
> yellow
> > pixels?
> > > > I'd like your opinion on this one.
> > > >
> > > > Herewith, I have attached two images that show a difference in the
> > > intensity
> > > > (one is yellow and the other one is pale), for your reference.
> > > > This difference is what I would like to measure.
> > > >
> > > > Best,
> > > > R
> > > >
> > > >
> > > > On Tue, Sep 1, 2015 at 5:12 PM, Burri Olivier
> > > > <[hidden email]>
> > > wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > If you select "Macro" from the Threshold Color window, it will
> > > > > give you a macro code you can run and get a mask that you can use
> > > > > "Create Selection" on
> > > > >
> > > > > However the question remains on what you are trying to measure on
> > > > > your original RGB image. From what I gather if you measure inside
> > > > > a selection, you will get the average of the red green and blue
> > > > > channels where you want the 'yellow color intensity' which is not
> really
> > that.
> > > > >
> > > > > I'd like others' opinions on this, but a better approach once you
> > > > > have your mask is to measure the Brightness component of your
> > > > > original image converted to HSB stack (Slice 3).
> > > > >
> > > > > Best
> > > > >
> > > > > Oli
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: ImageJ Interest Group [mailto:[hidden email]] On
> > > > > > Behalf Of ram prasad
> > > > > > Sent: Tuesday, September 1, 2015 16:08
> > > > > > To: [hidden email]
> > > > > > Subject: Batch color thresholder
> > > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > I would like to quantify yellow colour intensity on a number of
> > > > > > images,
> > > > > but I
> > > > > > am having trouble writing a macro for that purpose.
> > > > > >
> > > > > > I can get as far as opening the colour thresholder and applying
> > > > > > my
> > > > > cut-off's
> > > > > > but then selecting the region of interest is a bit slippery and
> > > > > > I'm
> > > > > hoping you
> > > > > > guys can help me out with this.
> > > > > >
> > > > > > This is what I'd intended to do.
> > > > > >
> > > > > > 1) Create a duplicate of my image  (Image -> Duplicate)
> > > > > > 2) Open the thresholder and select yellow pixels using the hue
> > > > > > slider
> > > > > (Image -
> > > > > > > Adjust -> Threshold)
> > > > > > 3) Then create a selection (Edit -> Selection -> Create
> > > > > > selection)
> > > > > > 4) Restore the selection on the original image (Edit -> Select
> > > > > > -> Restore
> > > > > > selection)
> > > > > > 5) Finally, measure Integrated density using (Analyze ->
> > > > > > Measure)
> > > > > >
> > > > > > The problem I have with the third step is that when I try to
> > > > > > create a
> > > > > selection
> > > > > > (using Edit -> Selection -> Create Selection) I get a pop-up
> > > > > > with the
> > > > > following
> > > > > > message,
> > > > > >
> > > > > > "This command creates a composite selection from a mask or from
> > > > > > an image that has been thresholded using Image -> Adjust
> > > > > > ->Threshold tool. The current image is not a mask and has not
> been
> > thresholded"
> > > > > >
> > > > > > I'm not sure why I'm getting this error here as I used Image ->
> > > > > > Adjust
> > > > > > ->Threshold to threshold my image.
> > > > > >
> > > > > > I'm attaching a sample image here for your reference. Please let
> > > > > > me know
> > > > > if
> > > > > > you need more information from my side.
> > > > > >
> > > > > > P.S the click operation on the Select button in the thresholder
> > > > > > dialog
> > > > > box
> > > > > > does not get recorded in the macro recorder that's why I'm
> > > > > > resorting to
> > > > > Edit -
> > > > > > > Select -> Create selection to create a selection.
> > > > > >
> > > > > > Thanks,
> > > > > > R
> > > > > >
> > > > > > --
> > > > > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> > > > >
> > > > > --
> > > > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> > > > >
> > > >
> > > > --
> > > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> > >
> > > --
> > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> > >
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Batch color thresholder

Olivier Burri
Dear Ram,

> The macro code worked!! Thank you very much. I find this very surprising
> because it looks identical to mine, but I did not run get as far as to running
> mine in batch. I kept getting that error and I didn't even bother using it for
> batch processing. So, all this time I was one foot away from the gold.

Glad that it worked, understanding the difference between your code and mine will definitely help you debug your subsequent projects faster :)

> Please have a look at the images and let me know what you think. Thanks
> again.

It does indeed seem correct and acceptable to use the hue slider to capture the part of the wing you desire to view. Be careful however of the brightness setting as in some images I could capture the wing area and in some others I could not.

Maybe a quick validation would be for you to measure the saturation on some manual ROIs and compare those values to your automatic pipeline to see if you are exaggerating or undermining the differences.

Best of luck

Oli

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Batch color thresholder

ram prasad
Hi again,

Today, I was running the macro on a new set of images and I noticed
something weird happening. I noticed discrepancies in the final results
obtained from manual analysis and macro.

When I run the macro on the image ed_10-1-1.jpg (
https://www.dropbox.com/sh/l0p0qb4h3fq2emx/AAAHIelRJI7gk2udVE5-WLJFa?dl=0)
I get a raw integrated density of 218334383.00000 but when I do the same
analysis manually I get a density of 96516272. I imagine something is going
amok in the step where I create a selection. I tried to check this by
commenting out close statements in the macro to be able to look at the
progress at each stage, but that failed. Could you help me out here?

Cheers,
Ram



On Fri, Sep 4, 2015 at 10:40 AM, Burri Olivier <[hidden email]>
wrote:

> Dear Ram,
>
> > The macro code worked!! Thank you very much. I find this very surprising
> > because it looks identical to mine, but I did not run get as far as to
> running
> > mine in batch. I kept getting that error and I didn't even bother using
> it for
> > batch processing. So, all this time I was one foot away from the gold.
>
> Glad that it worked, understanding the difference between your code and
> mine will definitely help you debug your subsequent projects faster :)
>
> > Please have a look at the images and let me know what you think. Thanks
> > again.
>
> It does indeed seem correct and acceptable to use the hue slider to
> capture the part of the wing you desire to view. Be careful however of the
> brightness setting as in some images I could capture the wing area and in
> some others I could not.
>
> Maybe a quick validation would be for you to measure the saturation on
> some manual ROIs and compare those values to your automatic pipeline to see
> if you are exaggerating or undermining the differences.
>
> Best of luck
>
> Oli
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html