Issues creating jpg thumbnails of objects

Greetings to all;
I’m trying to create thumbnails of identified objects in CP v2.1.1 using the following module pipeline:

LoadImages
IdentifyPrimaryObjects
SaveImages
LoadSingleImage
Resize
SaveImages

Essentially, I want to create a full size image of the primary objects and then reload and re-size it to create thumbnails.

However, at the re-size step I get the following error.

Error while processing Resize: shape mismatch: objects cannot be broadcast to a single shape


It seems that** this error only happens when then Resize module input image is the objects image **(from LoadSingleImage #4). If I select to resize the primary image from (LoadImages #1) then there is no error.

Any advice? Is there a better way to create thumbnails of object images?

Thanks and best regards
Ioannis


testPipeline_CPForum_20150714.cppipe (7.55 KB)

Hi @ioannismou,

I pondered this some time ago now, and while it is a great idea, I still can’t think of another way to create thumbnails within CP. Can anybody else think of a way to do this?

CPA has some of the required functionality to grab thumbnails of objects, but not all objects within an image or metadata group. So you could script/hack CPA to do this, i.e. not randomly select objects, rather, grab all of them that meet whatever criteria and display their thumbnails.

Cheers,
David

And as for the error, the pipeline uses SaveImages to save Objects but then LoadSingleImage loads the label matrix (i.e. the Objects) as an image. So it may be a logic issue. And CellProfiler’s pipeline design is not really suited to looping through objects and processing or saving them sequentially. (Aside: Also watch out for multi-threaded issues when you save images and then re-load them - you might not be getting the same image that you expected!).

David

Hi @davidlogan

Thanks for the feedback. You are raising some serious concerns about being able to create thumbnails from object images. It’s even more disappointing that this approach was tested successfully with the earlier version of CP (v2.0) and we had put it to good use in combination with our cluster processing where CP is running single-threaded. It sounds like I will need to investigate this further perhaps in combination with ImageJ or an external program (imagemagick?)

Would you have any suggestions if I was to do this through ImageJ which should be supported at least in principle better by CP?

Thanks and best regards
Ioannis

Hi Ioannis,

Give this a try:

  • Use ColorToGray to split the original Nuclei_Default_Default into the individual gray channels
  • Resize each one individually. Fortunately, you can use one Resize module with multiple images.
  • GrayToColor to merge the resized grayscale images back together into rthumb_Nuclei_Default_Default
  • SaveImages as you have before.

Uber-lame, but it works.
-Mark
EDIT: Filed as bug here: github.com/CellProfiler/CellPro … ssues/1416

Hi Ioannis,

Ah, I hadn’t realized you had this schema working in CP v2 before! Mark is checking to see if there is a bug to fix with ResizeImages, etc. And yes, running on cluster single-threaded should be fine with a single batch. Though if you have multiple batches concurrently running, I would expect issues writing and reading from the same folder.

Cheers,
David

Resize issue with color images has been fixed: github.com/CellProfiler/CellPro … ssues/1416

Ioannis, you could try a trunk build when it is finished building, in say, 15 minutes, and once it has today’s timestamp.
cellprofiler.org/cgi-bin/trunk_build.cgi

David

THANKS David and Mark.
Great feedback!
I will give the new version a try and post feedback.

Have a great weekend!
Ioannis