Thread Subject: Select part of an image with ginput

Subject: Select part of an image with ginput

From: Luis Di maio

Date: 18 Nov, 2009 17:48:20

Message: 1 of 5

hello
i want to select only a part of an image wich is given by ginput command:i'll explain better
i have an image,then select with ginput two points to build an eclipse on it-which represent the part i'm interested in.Now it's possible to take only this part and work on it,doing,for example,an histogram?there is a command to do it?
i know of imcrop but this will cut out the rest of the image while i need the whole image but i have to work only on the selected part...
someone can help me??thanks
best regards

Subject: Select part of an image with ginput

From: jrenfree

Date: 18 Nov, 2009 17:53:58

Message: 2 of 5

On Nov 18, 9:48 am, "Luis Di maio" <l.dim...@gmail.com> wrote:
> hello
> i want to select only a part of an image wich is given by ginput command:i'll explain better
> i have an image,then select with ginput two points to build an eclipse on it-which represent the part i'm interested in.Now it's possible to take only this part and work on it,doing,for example,an histogram?there is a command to do it?
> i know of imcrop but this will cut out the rest of the image while i need the whole image but i have to work only on the selected part...
> someone can help me??thanks
> best regards

Well I assume you know the equation for the eclipse you want to make
in order to get your x and y-values. You should just be able to use
those x and y-values to pull out the elements of the image matrix that
you want to use for your histrogram.

You'll want to use the hist command for that.

Subject: Select part of an image with ginput

From: Luis Di maio

Date: 18 Nov, 2009 18:22:04

Message: 3 of 5

jrenfree <jrenfree@gmail.com> wrote in message <1d2f0c3a-875d-47aa-a6a5-ae17051d9774@h40g2000prf.googlegroups.com>...
> On Nov 18, 9:48?am, "Luis Di maio" <l.dim...@gmail.com> wrote:
> > hello
> > i want to select only a part of an image wich is given by ginput command:i'll explain better
> > i have an image,then select with ginput two points to build an eclipse on it-which represent the part i'm interested in.Now it's possible to take only this part and work on it,doing,for example,an histogram?there is a command to do it?
> > i know of imcrop but this will cut out the rest of the image while i need the whole image but i have to work only on the selected part...
> > someone can help me??thanks
> > best regards
>
> Well I assume you know the equation for the eclipse you want to make
> in order to get your x and y-values. You should just be able to use
> those x and y-values to pull out the elements of the image matrix that
> you want to use for your histrogram.
>
> You'll want to use the hist command for that.

well,thanks for replying...
but actually i'm only taking with ginput the first point at the upper left corner and the second one at the lower right point of the area i'm interested in,then with 'rectangle' with curvature [1 1] doing an ellipse...and then want to select this part of the image....not possible?
regards

Subject: Select part of an image with ginput

From: jrenfree

Date: 18 Nov, 2009 18:31:08

Message: 4 of 5

On Nov 18, 10:22 am, "Luis Di maio" <l.dim...@gmail.com> wrote:
> jrenfree <jrenf...@gmail.com> wrote in message <1d2f0c3a-875d-47aa-a6a5-ae17051d9...@h40g2000prf.googlegroups.com>...
> > On Nov 18, 9:48?am, "Luis Di maio" <l.dim...@gmail.com> wrote:
> > > hello
> > > i want to select only a part of an image wich is given by ginput command:i'll explain better
> > > i have an image,then select with ginput two points to build an eclipse on it-which represent the part i'm interested in.Now it's possible to take only this part and work on it,doing,for example,an histogram?there is a command to do it?
> > > i know of imcrop but this will cut out the rest of the image while i need the whole image but i have to work only on the selected part...
> > > someone can help me??thanks
> > > best regards
>
> > Well I assume you know the equation for the eclipse you want to make
> > in order to get your x and y-values.  You should just be able to use
> > those x and y-values to pull out the elements of the image matrix that
> > you want to use for your histrogram.
>
> > You'll want to use the hist command for that.
>
> well,thanks for replying...
> but actually i'm only taking with ginput the first point at the upper left corner and the second one at the lower right point of the area i'm interested in,then with 'rectangle' with curvature [1 1] doing an ellipse...and then want to select this part of the image....not possible?
> regards

I'm not entirely sure, the the rectangle function doesn't return the x
and y-values that it's using to plot the ellipse. If you do:

h = rectangle(...);
get(h)

You might be able to pull out the x and y-values.

You would either need to be able to obtain those x and y-values from
the rectangle function or calculate them yourself from some ellipse
equation if you want to pull those pixels out of the image.

Subject: Select part of an image with ginput

From: Alex Taylor

Date: 23 Nov, 2009 18:11:20

Message: 5 of 5

"Luis Di maio" <l.dima83@gmail.com> wrote in message <he1c14$9a2$1@fred.mathworks.com>...
> hello
> i want to select only a part of an image wich is given by ginput command:i'll explain better
> i have an image,then select with ginput two points to build an eclipse on it-which represent the part i'm interested in.Now it's possible to take only this part and work on it,doing,for example,an histogram?there is a command to do it?
> i know of imcrop but this will cut out the rest of the image while i need the whole image but i have to work only on the selected part...
> someone can help me??thanks
> best regards

Please take a look at imrect and imellipse. These functions are in the Image processing toolbox. Both functions are ROI (Region of Interest) tools that are designed for interactively selecting regions of interest in an image.

doc imrect
doc imellipse

Take a look at the getPosition and createMask methods. The getPosition method can be used to query the position of the ROI tool over an image. The createMask method can be used to obtain a logical mask of the same size as the associated image that is true where the ROI is positioned and false otherwise.

Hope this helps,

Alex.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
imrect imellipse Alex Taylor 23 Nov, 2009 13:14:21
select image Luis Di maio 18 Nov, 2009 12:49:21
ginput Luis Di maio 18 Nov, 2009 12:49:20
rssFeed for this Thread

Contact us at files@mathworks.com