Hi all,
I'd like to run some convolutions on an image and rather than run each convolution in turn as the macro recorder prints it, like below: run("Convolve...", "text1=[0 0 0 0 0\n0 -1 -1 -1 0\n0 -1 12 -1 0\n0 -1 -1 -1 0\n0 0 0 0 0\n] normalize"); I'd like to set up a loop that will run through several convolutions. I thought i could add the convolutions to an array but not quite sure of the syntax of this in the macro language. I thought i could have a string array of the convolutions and then do something like: convolutions = newArray ("text1=[0 0 0 0 0\n0 -1 -1 -1 0\n0 -1 12 -1 0\n0 -1 -1 -1 0\n0 0 0 0 0\n] normalize"); run("Convolve…", [0]); I know what i've done is wrong but wondering if its possible and what are the correct statements to use? Thanks for the help, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Good day Matt,
not sure whether it helps in your case, but I use to store the kernels as a string in a file and then use: kernel = File.openAsString( path2kernel ); run( "Convolve...", "text1=["+kernel+"] normalize stack" ) This should also work without storing the kernels in a file. HTH Herbie ::::::::::::::::::::::::::::::::::::::::::::: Am 13.10.16 um 18:16 schrieb PEARSON Matthew: > Hi all, > > I'd like to run some convolutions on an image and rather than run > each convolution in turn as the macro recorder prints it, like > below: run("Convolve...", "text1=[0 0 0 0 0\n0 -1 -1 -1 0\n0 -1 12 -1 > 0\n0 -1 -1 -1 0\n0 0 0 0 0\n] normalize"); > > I'd like to set up a loop that will run through several convolutions. > I thought i could add the convolutions to an array but not quite sure > of the syntax of this in the macro language. I thought i could have > a string array of the convolutions and then do something like: > > convolutions = newArray ("text1=[0 0 0 0 0\n0 -1 -1 -1 0\n0 -1 12 -1 > 0\n0 -1 -1 -1 0\n0 0 0 0 0\n] normalize"); run("Convolve…", [0]); > > I know what i've done is wrong but wondering if its possible and what > are the correct statements to use? > > Thanks for the help, > > Matt > > -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute > of Genetics and Molecular Medicine (IGMM) University of Edinburgh > Crewe Road EH4 2XU > > > > > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by PEARSON Matthew
-------- Original message -------- From: PEARSON Matthew <[hidden email]> Date: 13/10/2016 22:53 (GMT+00:00) To: [hidden email] Subject: Re: Store convolutions in array Hi Herbie, Thanks for that it's good to know you can use a string that contains the kernel. Presumably altering this slightly as below to add in a string from an array wouldn't work. Kernel = newArray ("kernel1", "kernel2"); run( "Convolve...", "text1=["+kernel[0]+"] normalize stack" ) I'll play around with it tomorrow. I could always do it slightly less elegantly with a for loop and a series of if and else if statements to switch the kernel to Convolve with. run( "Convolve...", "text1=["+kernel[0]+"] normalize stack" ) Thanks, Matt -------- Original message -------- From: Herbie <[hidden email]> Date: 13/10/2016 20:09 (GMT+00:00) To: [hidden email] Subject: Re: Store convolutions in array Good day Matt, not sure whether it helps in your case, but I use to store the kernels as a string in a file and then use: kernel = File.openAsString( path2kernel ); run( "Convolve...", "text1=["+kernel+"] normalize stack" ) This should also work without storing the kernels in a file. HTH Herbie ::::::::::::::::::::::::::::::::::::::::::::: Am 13.10.16 um 18:16 schrieb PEARSON Matthew: > Hi all, > > I'd like to run some convolutions on an image and rather than run > each convolution in turn as the macro recorder prints it, like > below: run("Convolve...", "text1=[0 0 0 0 0\n0 -1 -1 -1 0\n0 -1 12 -1 > 0\n0 -1 -1 -1 0\n0 0 0 0 0\n] normalize"); > > I'd like to set up a loop that will run through several convolutions. > I thought i could add the convolutions to an array but not quite sure > of the syntax of this in the macro language. I thought i could have > a string array of the convolutions and then do something like: > > convolutions = newArray ("text1=[0 0 0 0 0\n0 -1 -1 -1 0\n0 -1 12 -1 > 0\n0 -1 -1 -1 0\n0 0 0 0 0\n] normalize"); run("Convolve…", [0]); > > I know what i've done is wrong but wondering if its possible and what > are the correct statements to use? > > Thanks for the help, > > Matt > > -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute > of Genetics and Molecular Medicine (IGMM) University of Edinburgh > Crewe Road EH4 2XU > > > > > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Just wanted to confirm for anyone else who isn't sure, you can run convolutions from an array, like so:
run("Convolve...", "text1=["+convolutions[i]+"] normalize stack"); Thanks again to Herbie. Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU On 13 Oct 2016, at 22:56, PEARSON Matthew <[hidden email]<mailto:[hidden email]>> wrote: -------- Original message -------- From: PEARSON Matthew <[hidden email]<mailto:[hidden email]>> Date: 13/10/2016 22:53 (GMT+00:00) To: [hidden email]<mailto:[hidden email]> Subject: Re: Store convolutions in array Hi Herbie, Thanks for that it's good to know you can use a string that contains the kernel. Presumably altering this slightly as below to add in a string from an array wouldn't work. Kernel = newArray ("kernel1", "kernel2"); run( "Convolve...", "text1=["+kernel[0]+"] normalize stack" ) I'll play around with it tomorrow. I could always do it slightly less elegantly with a for loop and a series of if and else if statements to switch the kernel to Convolve with. run( "Convolve...", "text1=["+kernel[0]+"] normalize stack" ) Thanks, Matt -------- Original message -------- From: Herbie <[hidden email]<mailto:[hidden email]>> Date: 13/10/2016 20:09 (GMT+00:00) To: [hidden email]<mailto:[hidden email]> Subject: Re: Store convolutions in array Good day Matt, not sure whether it helps in your case, but I use to store the kernels as a string in a file and then use: kernel = File.openAsString( path2kernel ); run( "Convolve...", "text1=["+kernel+"] normalize stack" ) This should also work without storing the kernels in a file. HTH Herbie ::::::::::::::::::::::::::::::::::::::::::::: Am 13.10.16 um 18:16 schrieb PEARSON Matthew: Hi all, I'd like to run some convolutions on an image and rather than run each convolution in turn as the macro recorder prints it, like below: run("Convolve...", "text1=[0 0 0 0 0\n0 -1 -1 -1 0\n0 -1 12 -1 0\n0 -1 -1 -1 0\n0 0 0 0 0\n] normalize"); I'd like to set up a loop that will run through several convolutions. I thought i could add the convolutions to an array but not quite sure of the syntax of this in the macro language. I thought i could have a string array of the convolutions and then do something like: convolutions = newArray ("text1=[0 0 0 0 0\n0 -1 -1 -1 0\n0 -1 12 -1 0\n0 -1 -1 -1 0\n0 0 0 0 0\n] normalize"); run("Convolve…", [0]); I know what i've done is wrong but wondering if its possible and what are the correct statements to use? Thanks for the help, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |