Thresholding only an ROI

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

Thresholding only an ROI

Rafael Ballester
Dear list,

the thresholding methods I have seen so far apply to the whole image, even if only a region is selected. Given an ROI, what is the easiest way (with ImageJ's Java API) to threshold only the pixels it contains?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Thresholding only an ROI

dscho
Hi,

On Wed, 15 Feb 2012, Rafael Ballester wrote:

> the thresholding methods I have seen so far apply to the whole image,
> even if only a region is selected. Given an ROI, what is the easiest way
> (with ImageJ's Java API) to threshold only the pixels it contains?

The easiest is to Edit>Clear Outside before thresholding. This changes the
image pixels, of course, so you might want to Image>Duplicate... it
before.

Ciao,
Johannes
Reply | Threaded
Open this post in threaded view
|

Re: Thresholding only an ROI

David Webster
In reply to this post by Rafael Ballester
The Clear Outside operation seems to just zero the pixels outside of the
ROI. This may still bias the threshold calculation. Try duplicating the
ROI, and then run the threshold on the ROI image.

David Webster

On Wed, Feb 15, 2012 at 1:50 PM, Rafael Ballester <[hidden email]> wrote:

> Dear list,
>
> the thresholding methods I have seen so far apply to the whole image, even
> if only a region is selected. Given an ROI, what is the easiest way (with
> ImageJ's Java API) to threshold only the pixels it contains?
>
> Thanks.
>
Reply | Threaded
Open this post in threaded view
|

Re: Thresholding only an ROI

Cammer, Michael
In reply to this post by Rafael Ballester
  // example simple method to threshold only a ROI
  // Only works for 8 and 16 bit images.

  threshold = 220;   // this is the threshold value, set for whatever you need

  if (bitDepth()  == 8) maximum=255;
  if (bitDepth() == 16) maximum=65535;
  changeValues(0, threshold, 0);
  changeValues(threshold+1, maximum, maximum);

________________________________________________________
Michael Cammer, Assistant Research Scientist
Skirball Institute of Biomolecular Medicine
Lab: (212) 263-3208  Cell: (914) 309-3270


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Rafael Ballester
Sent: Wednesday, February 15, 2012 4:50 PM
To: [hidden email]
Subject: Thresholding only an ROI

Dear list,

the thresholding methods I have seen so far apply to the whole image, even if only a region is selected. Given an ROI, what is the easiest way (with ImageJ's Java API) to threshold only the pixels it contains?

Thanks.

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================
Reply | Threaded
Open this post in threaded view
|

Re: Thresholding only an ROI

Olivier Burri
Hello,

From my trials and understanding of Thresholding in ImageJ/Fiji, here is a bit more data

When you select a ROI and then launch "Threshold..." the Threshold is meaured ONLY from the pixels INSIDE the ROI. Therefore "Clear Outside" does NOT bias the Thresholding, which is why Johannes suggested it.

So you can either use the small macro by Michael or
1. Duplicate Image
2. Select ROI
3. Clear Outside
4. Apply your selected Threshold (whether you do this after or before "Clear Outside" has no impact)
5. Restart as necessary by re-selecting the original image window and a new ROI.

This has the advantage that you can have one image per ROI, and that the ROI is of the same size as the original.
You can then recombine these images to form a single mask if the masks are well separated or use them individually on your subsequent calculations.

Best

Oli


Olivier Burri
Engineer, Development in Image Processing
BioImaging and Optics platform (PTBIOP)
Tel: [+4121 69] 39629

________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Cammer, Michael [[hidden email]]
Sent: Thursday, February 16, 2012 5:14 PM
To: [hidden email]
Subject: Re: Thresholding only an ROI

  // example simple method to threshold only a ROI
  // Only works for 8 and 16 bit images.

  threshold = 220;   // this is the threshold value, set for whatever you need

  if (bitDepth()  == 8) maximum=255;
  if (bitDepth() == 16) maximum=65535;
  changeValues(0, threshold, 0);
  changeValues(threshold+1, maximum, maximum);

________________________________________________________
Michael Cammer, Assistant Research Scientist
Skirball Institute of Biomolecular Medicine
Lab: (212) 263-3208  Cell: (914) 309-3270


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Rafael Ballester
Sent: Wednesday, February 15, 2012 4:50 PM
To: [hidden email]
Subject: Thresholding only an ROI

Dear list,

the thresholding methods I have seen so far apply to the whole image, even if only a region is selected. Given an ROI, what is the easiest way (with ImageJ's Java API) to threshold only the pixels it contains?

Thanks.

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================
Reply | Threaded
Open this post in threaded view
|

Re: Thresholding only an ROI

Rafael Ballester
In reply to this post by Rafael Ballester
Finally I went with the ROI duplication strategy. Thank you all!