Posted by
bnorthan on
Sep 05, 2013; 3:55pm
URL: http://imagej.273.s1.nabble.com/Automating-Image-Processing-and-Problems-with-FFTJ-tp5004660p5004675.html
Hi Aaron
The first part of your question is relatively simple. (Last year I
attended a good course at Havard by Lai Ding, (held twice a year I
think?)... he did a very good job of going over how to write loops in
Macros to process/create multiple images/files.)
Something like the code below should work... (note that I had to reopen the
original image each time through the loop... I suspect there could be a
more elegant way of doing it by somehow forcing crop to make a new image
each time).
open("/SomeDirectory/image.tif");
baseName="/SomeDirectory/profile";
height=getHeight();
width=getWidth();
for (h=0;h<height;h++)
{
makeRectangle(0, h, width, 1);
run("Crop");
name=baseName+h+".tif";
saveAs("Tiff", name);
open("/SomeDirectory/image.tif");
selectWindow("image.tif");
}
I believe the second part of your question requires some understanding of
java and imagej internals. The source code is provided with the FFTJ
plugin so it is possible to take a look at it and modify it. It looks like
the FFTJ plugin shows 2 dialogs. The first one is an imagej
"GenericDialog", the second one is just a java "frame".
So what is the importance of that?? Basically the second dialog is not
implemented using the imagej framework... so the macro recorder doesn't
record interactions with it and won't skip showing it when running in a
script.
To get the behaviour you want you probably have to modify the source code.
The changes required aren't too complicated but you need a bit of java (you
would need to eliminate the code that shows the second dialog box and just
go directly to the code that creates and shows the power spectrum).
Brian
On Thu, Sep 5, 2013 at 7:45 AM, Aaron Hendrickson <
[hidden email]> wrote:
> Hello,
>
> I am doing some analysis on image sensor quality using the EMVA 1288
> standard. One of the tests I am conducting is referred to by the 1288
> standard as "vertical and horizontal spectrograms". In order to create the
> horizontal spectrograms, I need to take a single image (32-bit grey tiff)
> save each row of the image as a separate tiff file, and then generate a
> 32-bit Power Spectrum. The same process is done to create vertical
> spectrograms except the columns are used instead.
>
> Since I do not have any Java experience, I have been using the macro
> recorder in to record these steps and create a macro to do this on the fly.
> However, I am running into several problems. First, I can't figure out
> how to automate the cropping and saving of the rows and columns. Here is a
> the macro I recorded to create one row:
>
>
> open("C:\\Users\\Owner\\Documents\\ATR\\cam_testing_images\\NAC_GX-1_monochrome_SerialNo.1200\\NAC_GX-1_mono_flat_images\\normal_gain_flats_8.22.11\\normal_gain_flats_originals\\3600us_4diffuser\\3600us_4diffuser_000009.tif");
> makeRectangle(0, 0, 510, 1);
> run("Crop");
> saveAs("Tiff", "C:\\Users\\Owner\\Desktop\\rows\\00.tif");
> close();
>
> I then have to copy and paste this code a couple hundred times, change the
> ROI, and increment the file name just to generate the rows or columns.
> Does anyone have any suggestions for how to automate this process such
> that I can take an image of any resolution and automate the process of
> saving all its rows and columns separately?
>
> The next issue I am running into is generating and saving a 32-bit Power
> Spectrum for each row and column image. Again, I recorded the steps I took
> to create a PS for one row image using FFTJ:
>
> run("FFTJ ", "real=[00.tif] imaginary=<none> complex=[Double Precision]
> fft=forward");
> selectWindow("Power Spectrum With Origin At (0,0,0) (Double Precision)");
>
> I again took the code and copied it many times while incrementing the image
> name as to do this in a somewhat automated fashion. When I did this I get
> an error and IJ will not create even the first PS image because after FFTJ
> is ran (first line of code) the user then has to click the show PS button
> in FFTJ's GUI. For whatever reason the macro recorder does not record me
> clicking the "Show PS" button and therefore I cannot automate that either.
>
> Therefore, my second question is how to automate creating the PS for each
> row or column image using FFTJ.
>
> I apologize for the long email and would greatly appreciate any help
> someone could provide me. It would save me an incredible amount of time
> copying code and clicking buttons.
>
> Respectfully,
> Aaron
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html