I need to do some measurements on a bulk of images using fiji mcaro language. I need to set a scale one time at first and macro does the calculations on all images. I realized that when I set scale and close the current image it resets to its default mode. Is there any way to fix set scale which could be able to apply to all images?
If you know the scale(s), apply it in a macro as shown below. I say scale(s) because sometimes there is a slight aspect ratio to the image (especially SEM…). Measure a standard oriented along the width and height of your images… Substitute your values…
Depending upon your instrument, the values may be in the image metadata. Try importing the image with the Bioformats Importer (type Bioformats in the search bar) and check the image properties. It is always nice when the vendor has done the work for you…
run("Properties...", "channels=1 slices=1 frames=1 unit=um pixel_width=.2 pixel_height=.2 voxel_depth=.2");
What I do is that I sketch a line on the scale bar of the image and go to the set scale menu and add the size of that line.
I need to do it once and then for all images, have the same scale without being reset for each image.
Also since I am working with macro language which process on many images simultaneously I want to set the scale before running the macro and then run the macro.
Please show me a way to set the scale with scale bar as I do not have access to the metadata now.
You have to enable the global option in the set scale dialog. This will open the images with the selected scale for one ImageJ session, see:
A global scale is indicated with a (G) in the image window (see screenshot below)
You can also execute a macro command like (global scale):
run("Set Scale...", "distance=1 known=0.5 unit=mm global");
Use the macro recorder to get the GUI commands as a macro command:
In this way you can also set a preferred line and scale bar automatically.
@Bio7 Thanks. From the link, it says: " When Global is checked, the scale defined in this dialog is used for all opened images during the current session instead of just the active image". This means that global is only applied to open images which means it wont get applied if I close current image and open an other one. I need to do set scale once and it will be applied to all images no matter they are closed and reopened.
When I close all images and open a new image the global scale is still applied.
As I wrote you can also put the run command to set the scale for each image, e.g., in the Batch dialog to set the scale for each image:
run("Set Scale...", "distance=2 known=1 pixel=1 unit=mm");
If you read the post on the Forum site you will see that I included a ijm macro language line of code to do just that… Complete with syntax coloring