Login  Register

Re: painting an overlay

Posted by Rasband, Wayne (NIH/NIMH) [E] on May 03, 2014; 2:47am
URL: http://imagej.273.s1.nabble.com/painting-an-overlay-tp5007497p5007554.html

On May 2, 2014, at 12:53 PM, Kenneth Sloan wrote:

> RTFM lead me to the conclusion that this is not a “stock operation” in ImageJ.  Unless I’m missing something, a current Overlay can only consist of stroke graphics elements.  I need a RasterOverlay.
> It doesn’t look all that hard for me to implement, but it will mean implementing “yet another paintbrush tool”.
> Before I start - has anyone done this?  Is anyone working on it?

Using an ImageRoi in an overlay would be a good starting point. An ImageRoi can be any image, including binary images, and the opacity can be set. It would probably not be hard to get the existing drawing tools to work with an ImageRoi in an overlay.

There are several existing commands that you can use to experiment with ImageRois. The Edit>Selection>Image to Selection command converts an image into an ImageRoi. The Image>Overlay>Add Image command converts an image to an ImageRoi and adds it to an overlay. You can change the opacity of an ImageRoi using the Edit>Selection>Properties dialog. There is an example plugin at

   http://imagej.nih.gov/ij/plugins/image-overlay/index.html

that creates an ImageRoi from an image, adds it to an overlay and rotates it 360 degrees. The source code for the ImageRoi class is at

   http://imagej.nih.gov/ij/developer/source/ij/gui/ImageRoi.java.html

-wayne

> And, of course, is this a reasonable feature to request in future versions?
>
> I’m taking “No Answer” to the previous query as an indication that this isn’t “stock ImageJ”.
>
> Again, I think the core operations are:
>
> a) convert binary image to “RasterOverlay” and back again
> b) use standard paintbrush tools to paint on the overlay
>
> I’d also like to specify the opacity of the overlay - that may already exist for the current overlay
> feature, but I haven’t found it yet, and I’ve stopped looking because it looks like I’ll be
> writing my own version.
>
> Before I start - anyone with a “wish list” of features?  At first glance I’ll want draw/erase, set color, set opacity, perhaps turn “overlay” on/off, and convert “overlay” to/from 8-bit Binary image.  Anything else? Are there standard conventions on what to do if, say, the input Binary image has a size that is different from the gray-scale image being overlaid?  Could this be done with a heterogeneous Stack (containing two images, gray-scale and binary, with some wort of blending rule)?
>
> All clues gratefully rented.  I’ll probably start on this…Wednesday, 7 May.
>
> In case anyone cares, what I’m doing is building a tool to allow a trained observer to edit a binary mask.  The binary mask produced by automatic means is very good - but not *quite* good enough.  So, there will be a single plugin to
> produce the initial mask and then allow the observer to edit it.  Final output is simply the edited mask, written as a .png file.  Programs further down the pipeline (probably *not* ImageJ programs) will start from the original image and the binary mask and do …whatever…
>
> The point is that it is useful to see the gray values under the mask, especially when making decisions about ERASING parts of the mask.  Right now, we’re doing this “side-by-side”, which works fairly well, just not as nicely as I’d like.
>
> …on the road to ARVO…if any ImageJ hackers will be there…let’s do lunch.
>
> --
> Kenneth Sloan
> [hidden email]
>
>
> On Apr 29, 2014, at 18:15 , Kenneth Sloan <[hidden email]> wrote:
>
>> I am looking for help on a feature that I think exists, but I have never used.
>> The answer is probably RTFM, but I would appreciate a few hints.
>>
>> Here’s what I want to do:
>>
>> a) I have a plugin that accepts any type of image, makes a copy, converts to 8-bit
>>  and then uses auto local thresholding to create a binary mask
>> b) I would like to give a trained observer the option to PAINT in the thresholded image
>>  to correct errors made by the auto local threshold
>> c) That works now - except that the user has little guidance correlating the gray-scale
>>  image with the binary mask
>> d) So…I would like to OVERLAY the binary mask on the grayscale image and allow the observer
>>  to paint the OVERLAY
>> e) and then…at the end…I need to convert the overlay to an independent binary mask image.
>>
>> The parts I don’t know how to do are:
>>
>> * convert binary mask to an overlay on the original gray-scale image
>> (it’s ok, of course, to do this on a COPY of the original, since the original
>>  may not be 8-bit in the first place)
>> * draw/erase the overlay (are there paintbrush tools available to work on an overlay?)
>> * convert the final overlay to a binary image.
>>
>> Pointers to the documentation, or example code that does something even vaguely similar, would be
>> most appreciated.
>>
>> --
>> Kenneth Sloan
>> [hidden email]
>>
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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