Need to enlarge multi-point tool

plugin
roi
macro
Tags: #<Tag:0x00007fb883fb8838> #<Tag:0x00007fb883fbfea8> #<Tag:0x00007fb883fbfbb0>

#1

Hi all,

I’m using ImageJ to count objects in my image.

For the purpose of my application, I need to count the objects in each region and save the count in a spreadsheet. However, for documentation purposes, I must retain the marks on the image. To retain the marks on the image, I’ve been using Ctrl+D to draw the mark on the image, and Ctrl+B to burn-in the marks. However, what I’ve realized is that although the circles (that I use for multipoint counting) is large in a small zoom scaling, the points/circles are scaled to its default size after exporting as the size of the points/circles are dependent on the image’s 100% scale size. Because the resolution of the image is quite high, I the circles end up being really small.

Methods like Capture Screen, and Capture Image do not capture the full resolution of the original image and is thus problematic. The photo resolution is much higher than my screen’s, so the image will always be zoomed in on my screen and never at 100% scaling to retain the original quality.

tl;dr: Need to make the mult-point count marks larger, one way or another, upon exporting without losing quality of the image.

Whether this can be accomplished by writing my own macro, modifying ImageJ, plugin, roi, or whatever, I need a way to meet my requirements one way or another.

Please help!


#2

Hi Tim,

Welcome to the ImageJ forums!

What sort of images are you starting with, .tiff? And what are you doing to the image after you’ve added the points to the overlay (ctrl+b)?

I tried zooming on an image and placing multi-points and then saving the image and returning to it, it doesn’t seem to replicate your problem though. The points seem to be fine, they still scale with the image zoom, and are large enough.

What sort of exporting are you doing and why?

Cheers,
Rob


#3

The files I am processing are .jpeg but I’ve been converting them to png although i am not sure there is a major difference between these?[quote=“7rebor, post:2, topic:6138”]
I tried zooming on an image and placing multi-points and then saving the image and returning to it, it doesn’t seem to replicate your problem though. The points seem to be fine, they still scale with the image zoom, and are large enough.
[/quote]

For the purpose of this assignment, I need to count items on the image and show on a separate version of the image the places where I’ve placed my multi-count pointers. Because ImageJ allows you to zoom-in and look closely at the image and place counters. The problem is that these counters scale with your image-scaling in ImageJ, so if I pressed Ctrl + to zoom-in, the counters would remain the same size while my image would zoom-in. This is fine but when I export the photo, using File > Save As, ImageJ would draw the counters/pointers as they would look if the image was scaled at 100%. Since the image is rather large, the counters/pointers look rather small in comparison, almost invisible if I zoomed out of the image to show the full thing. Basically, I have to show these images on a powerpoint and show that, “yes I’ve done the counting”, and “these are the items that I counted”. But if the pointers are too small such that they are invisible on a PPT, then I am in trouble.

The problem with this is that I need to show the counters/pointers when the image is zoomed out, without losing pixels by down-sizing the image so the pointers would look large enough.

Or, I could simply make the pointers/counters large enough in the first place that I wouldn’t have to do Image > Adjust > Size to down-size the image but instead keep it as is.

The end result that I need is the original image with no modifications and a modified image with the counters/pointers next to the items that I need to count, thereby showing all the “work” I’ve done for documentation.


#5

Rob,

for further demonstration I’ve uploaded some demo images to the following link: http://imgur.com/a/eD1yt

I cannot just use Plugins > Utilities > Capture Image because Capture Image takes the photo at the current scaling, which if I zoomed all the way out to see the full photo would be 16.7% scaling. 16.7% would mean that I retain only 16.7% of the original resolution, which is not acceptable for my use-case.


#6

The image overlay is scaled to 100% zoom when the image is flattened (you can also reproduce this using Image > Overlay > Flatten.

A similar issue was discussed here:

In short: the easiest solution is to downsample the image to keep for documentation, and keep the original image at full resolution without the burned-in overlay.


@timhuang77 you can work around the issue by creating an OvalRoi for each point of your multi-point selection. The following Groovy script illustrates this (just run it from the script editor after choosing Language > Groovy; try it on a large canvas with an active multi-point selection):

#@ ImagePlus imp

import ij.gui.Overlay
import java.awt.Color
import ij.gui.OvalRoi
import ij.gui.PolygonRoi

ovl = new Overlay()
roi = imp.getRoi()

if (roi instanceof PolygonRoi) {
	p = roi.getPolygon()
	[p.xpoints, p.ypoints].transpose().each { x,y ->
		circle = new OvalRoi(x-50, y-50, 100, 100)
		circle.setStrokeWidth(10.0)
		ovl.add(circle)
	}
}

imp.setOverlay(ovl)

The follow shows (1) the original window, (2) after flattening, (3) after running the script and flattening (all at 8.3% zoom):


#7

@imagejan Thanks for you help. How can I get your script to work? When I run the script and press Ctrl + Shift + F nothing happens, the counters are still very small.

I use Ctrl + B to add the counters as a selection. Then use Ctrl + Shift + F to flatten image. I run the script before doing any counting with the image.


#8

With Ctrl+B you’re adding the current active selection to the overlay, but that won’t solve the issue when flattening or exporting, since (multi-)point ROIs are always rendered to 100% when flattening.

You’ll need to run the above script and then flatten the image.

Did you try pasting it into the script editor, choosing Language > Groovy, and pressing the Run button, as I suggested above?

Have a look at the Scripting basics to get an understanding of what’s being done in the script.


#9

I’m finding that if I use Ctrl + B to add selection to overlay, the script you provided only flattens the current active selection.

If, for example, I select a set of items, press Ctrl + B to add to overlay, then select a few more items, then press Ctrl + B to add to overlay, and then run the script, my pointers disappear.

For example,

the first image shows the flattened image without pressing Ctrl + B. This is what I need but I would like to use multiple series of point selection hence the Ctrl + B

the second image shows the image in ImageJ that I intend for my finished image to look like.

After I run the script however, everything disappears in the flattened image (or maybe becomes to small to recognize)

@imagejan I’m also noticing that the counters disappear? I apologize. I am not too familiar with imagej only started using this a couple weeks ago and I don’t completely understand overlays, ROI’s, etc.


#10

Yes, the script will only take the active selection, as you can see from this line:

roi = imp.getRoi()

And as I stated above, using Ctrl+B will not solve your issue. :slight_smile:

I you have an overlay (or more than one selection, e.g. from the ROI manager), you will have to adapt the script to your needs.
The script above was meant to serve as an illustrative example to show what you can do to work around a shortcoming of the ImageJ 1.x point ROIs. Sorry that I don’t have more time to work out a full solution for you. Maybe others with more time can help you here on the forum.

You can read more about overlays and ROIs in the user guide, and refer to the Overlay API for scripting.


Also, maybe @Wayne wants to comment if this behavior can be tweaked to be more user friendly without the need of scripting.


#11

Ah I see. Thanks a lot for your help!


#12

I am working on a fix for the Flatten command so that it works as expected with high-resolution images containing point selections.


#13

Try the Flatten command in the latest ImageJ daily build (1.51q20). It should work as expected with point selections, and point selections in overlays, on high resolution images as long as the point type is “Circle”. You can upgrade by using the Help>Update ImageJ command and selecting “daily build” from the drop down menu.


Fiji - marking selected points
Beginner help please! Overlay & capture image issue
#14

@timhuang77, is the multi-point tool problem you were experiencing fixed in the ImageJ daily build? With the latest build (1.51q22), the Flatten command should work correctly with all point types on high-resolution images.


#15

@Wayne Thank you! I’m assuming that Flatten is going to flatten to exactly how it looks on the screen? (At least that’s how it’s working for me currently). If so, then it works!

I really appreciate the speed at which you worked on this! You cannot believe how much effort you will help me save at work. Truly much appreciated.

Edit: I tried this on the 1.51q24 daily build since I did not have time the last couple days to try the previous builds.