Thresholding a masked image

Hello,

First off thank you for providing such a useful program, Cell Profiler is a great resource and will hopefully be playing a large roll in my research. I am using the program for its straightforward image analysis pipeline and integration to matlab, however I am not using it to analyze cells. I am colelcting timelapse pictures of snow accumulation on solar panels with the goal of characterizing snow shedding performacne of panels. As such, I have a photograph of a field of panels, and have created a binary mask image to locate each panel in the frame. After masking each panel I threshold each masked panel seperately using otsu threshold with a minimum set at 0.5. Generally speaking, I am looking for white snow on a black panel, and therefore there is a clear seperation, however on some overcast or snowy days the contrast between panel and snow is not that great, thus my desire to use an adaptive algorithm.

The issue I am running into is that the Otsu thresholding will consistantly choose the 0.5 threshold, and what I suspect is happening is it is averaging over the entire photograph, which is weighted heavily black after the mask operation, casuing the algorighm to always jump to its lowest threshold value. Is there a way of making the threshold operation consider only the area inside of the mask when performing its weighting? Or is this already happening and do I have another issue?

I’ve attached my pipeline

Thanks for your help

Rob A.
Queen’s Applied Sustainability Group
ThresholdtestbatchPIPE.cp (49.9 KB)

I don’t have the exact answer because I’m currently primarily using imageJ, but I solve the problem in imageJ by duplicating a selection and performing my operations on the duplicated, selected areas. I’m sure there are some commands in CellProfiler that will do the same thing, or, at the very least, it appears that you can launch imageJ from CellProfiler.

Would you mind uploading one of your photograph of a field of panels, plus a binary mask, so we can take a look at how your pipeline works on a real case?
-Mark

I’ve attached two images and two binary masks from the program

Thanks for your help








Another related quesiton, I would like to save each individual thresholded panel image as a record of the shape of the snow shedding. I am using the OutputExternal module, but I can’t find where these files are going. Is there a way to save the thresholded images as seperate .jpg or in a format that can be read by matlab?

Cheers,

There are two items to look at:

  • You probably want to use Otsu per-object thresholding rather than global. This will insure that the threshold is being evaluated over the ROI.
  • More importantly, your lower bound in ApplyThreshold is 0.5, meaning that the threshold will never go lower than 0.5. Set this to 0.0 for the maximum range of threshold freedom.

As an aside, if the panels are not touching, you can condense the pipeline by creating a single binary image of all panels together. Then you can load this binary image using LoadSingleImage, and use IdentifyPrimaryObjects to identify each panel as an object using a manual threshold. You can then use MeasureObjectIntensity to evaluate the intensity of each individual panel on the snow image, or MeasureImageIntesnity for all panels. Finally, you can use ExportToSpreadsheet to export the per-panel and/or per-image results.
-Mark