makeRectangle Problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

makeRectangle Problem

mamech
Hello

I am trying to embed imagej in a java application, as I need to do the following sequence of operations on a passed image:
1-make rectangle around certain area.
2-Crop

The problem is the step of making rectangle does not work.

Here is a piece of code:

implus.setImage(bf); //bf is a buffered image
ij.run(implus, "Make Binary", ""); // converting to binary
ij.makeRectangle(30, 30, 30, 30);
implus.show();

The output of the program:
There are no images open.

and then the application stops.

Can any one tell me how I can do the operation of making rectangular selection on a passed image or buffered image?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: makeRectangle Problem

mamech
Hello

Are here anybody who knows how to solve the above mentioned problem? or at least a workaround for it?

If I do not get the answer from imagej forum itself, this means almost that I will not find the answer elsewhere.

I am sure that solution is easy.

Can anyone help me?
Reply | Threaded
Open this post in threaded view
|

Re: makeRectangle Problem

Albert Cardona-2
2011/4/28 mamech <[hidden email]>:

> Hello
>
> Are here anybody who knows how to solve the above mentioned problem? or at
> least a workaround for it?
>
> If I do not get the answer from imagej forum itself, this means almost that
> I will not find the answer elsewhere.
>
> I am sure that solution is easy.
>
> Can anyone help me?--
> View this message in context: http://imagej.588099.n2.nabble.com/makeRectangle-Problem-tp6283379p6315221.html
> Sent from the ImageJ mailing list archive at Nabble.com.


Start here:

http://albert.rierol.net/imagej_programming_tutorials.html#ImageJ
programming basics


Albert

--
http://albert.rierol.net
http://www.ini.uzh.ch/~acardona/
Reply | Threaded
Open this post in threaded view
|

Re: makeRectangle Problem

BenTupper
In reply to this post by mamech
On Apr 28, 2011, at 7:26 PM, mamech wrote:

> Hello
>
> Are here anybody who knows how to solve the above mentioned problem?  
> or at
> least a workaround for it?
>
> If I do not get the answer from imagej forum itself, this means  
> almost that
> I will not find the answer elsewhere.
>
> I am sure that solution is easy.
>
> Can anyone help me?--

Hi mamech,

It makes it easier to understand what you are asking for if you quote  
the original question.  For those who are missing context, the  
original question can be found here... http://tinyurl.com/3un7xvc

I can only guess, but since "imp" is not argument to IJ.makeRectangle  
then ImageJ will look for open images.  If there are none (because you  
are working in memory) then it seems reasonable to get the error  
"There are no images open."

Have you considered using the ImagePlus.setRoi method instead if  
IJ.makeRectangle?

Cheers,
Ben
Reply | Threaded
Open this post in threaded view
|

Re: makeRectangle Problem

mamech
In reply to this post by Albert Cardona-2
Thank you for the link

I tried before to make it in "High level way" but I did not succeed.

The sequence that I asked for, was translated to the following commands using macro recorder of imagej:

open("C:\\Users\\mostafa\\Desktop\\Smarty\\Recognition\\Test2\\inventory\\2.jpg");
makeRectangle(84, 28, 175, 95);
run("Crop");

So I am supposed to interpret these into java form.
implus.setImage(bf); // This is instead of open command

ij.makeRectangle(84, 28, 175, 95); // This is the only makeRectangle that I found and it has no effect

ij.run(implus, "Crop", "");// instead of crop


This is the same problem that I faced before. command like crop is a high level and can be dealt with ij.run(target,command), but for makeRectangle it seems to be midlevel and should be dealt using ij.makeRectangle. How can I mix between both of high and mid level?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: makeRectangle Problem

mamech
In reply to this post by BenTupper
I tried with implus.setRoi, but it has also no effect.
Reply | Threaded
Open this post in threaded view
|

Re: makeRectangle Problem

Michael Schmid
In reply to this post by mamech
Hi Mamech,

ij.makeRectangle  works only if the ImagePlus is the foreground image  
(you have to call its show method for that). Otherwise, use  
ImagePlus.setRoi with a suitable rectangular roi.

Michael
________________________________________________________________

On 1 May 2011, at 01:37, mamech wrote:

> Thank you for the link
>
> I tried before to make it in "High level way" but I did not succeed.
>
> The sequence that I asked for, was translated to the following  
> commands
> using macro recorder of imagej:
>
> open("C:\\Users\\mostafa\\Desktop\\Smarty\\Recognition\\Test2\
> \inventory\\2.jpg");
> makeRectangle(84, 28, 175, 95);
> run("Crop");
>
> So I am supposed to interpret these into java form.
> implus.setImage(bf); // This is instead of open command
>
> ij.makeRectangle(84, 28, 175, 95); // This is the only  
> makeRectangle that I
> found and it has no effect
>
> ij.run(implus, "Crop", "");// instead of crop
>
>
> This is the same problem that I faced before. command like crop is  
> a high
> level and can be dealt with ij.run(target,command), but for  
> makeRectangle it
> seems to be midlevel and should be dealt using ij.makeRectangle.  
> How can I
> mix between both of high and mid level?