Cropping out Corners of an Image

Hi there,

I was wondering what the best method would be for CP to ignore the four corners of my images. The images I input in are images that have the well that we’re looking at and black space surrounding it. In my pipeline, I’ve been using a Crop module with an ellipse function basing the said ellipse off the center and creating a circle to signify the well, but I’ve recently run into some problems with a different set of images where that center was shifted.

Is there any module that can apply a crop that can ignore the black space from the IdentifyPrimObjects module without me having to input values for manual cropping?

I’ve attached my pipeline and an example image on Google Drive below. Thanks much!

Take a look at the example pipeline for yeast colony classification, which involves aligning a round yeast plate to a template - you are in luck because that pipeline comes with a written tutorial - it’s old but the concepts should still be valid. You can make your own template that is the funky shape in your images (you needn’t use a perfect circle as in this example).

Okay sounds good, I’ll try that out. Do you know how I can make a template of the region that I want?

See the tutorial, does it describe options?. Photoshop or ApplyThreshold in CellProfiler, IIRC.

Hi Anne,

I tried out the method in the Yeast Colonies tutorial by using the example template and a template that I created through one of my images, but I’m not getting the results I want.

I’m not sure if you have taken a look at the image I posted earlier, but I think the difficult part about my images is that I don’t have a closed well. Basically, my image is a zoomed in rectangular image of a well that cuts off the four farthest sides of the well. Thus, the image has an individual black area in each corner that varies in size depending on how the plate was placed on the imaging machine.

For example, if the plate is placed perfectly center, the four black areas are similar in size where the center of the well is the center of my rectangular image. If the plate is moved a slight distance towards the upper left, then the top left black area is smaller than the bottom right black area.

The template I created for the align module uses a template of a plate that is perfectly centered, but when I put it through the pipeline, the program stalls.

So the questions I have again:

  1. Is the align module the module that is suitable for my images as described above?
  2. Does the huge size of my images (4320x4320) affect the align module?

Thank you so much again. You and your team are a fantastic help.

I had a similar problem in one project, where I had the entire well edges on the imiage borders. Of cause the microcope stages and the plate calibrarions are not so precise that these edges will be always at the same position.

My solution was the following:

  • invert the image
  • smooth the image (big Gaussian radius)
  • Identify Primary object (with file holes, no splitting) to get the whole well as one big object
  • mask the outside of that object for further image processing of you initial images
    Hope that helps…


1 Like

That’s a great suggestion especially for round plates.

If that doesn’t work, then we should investigate why align is stalling out… That is likely something we can address because it sounds like a memory issue rather than a failure to align. You might attach a .cpproj file and your images, including the template so we can see what’s going and our adjust settings. Or try a computer with more horsepower/memory.

@Anne_Carpenter ‘Align’ is a HUGE memory hog , so that wouldn’t surprise me at all.

Indeed! I forget if there are any built-in options to down-sample to make it go faster - I assume no?

There are different alignment algorithms, but no, no other built-in way (though presumably you could resize both, align, then resize back to the full size again).

Thanks for the suggestion Martin!

I actually came up with a similar method last night following these pipeline:

  • ImageMath: invert
  • ApplyThreshold (binary + otsu)
  • Morph (Fill small holes)
  • MaskImage
    and then IdentifyPrimaryObjects to find my cells.

And @Anne_Carpenter and @bcimini,
I tried the Align module on a Linux computer with 32 core processors and noticed something a little weird. The CP program would overload one processor, then use all 32 processors for a split second, and go back to only using one processor. Do you know why that is?

1 Like