Thread Subject: backround image to a graph

Subject: backround image to a graph

From: recep mansiz

Date: 14 Jul, 2009 06:26:03

Message: 1 of 5

Hi all!!

I want to put a backround image to my graph so the values can be seen on this image.

I cannot fix the graph and photo correctly. does anybody have any idea how to place the image correctly to tha graph??

below I put three different implementation of the same code.

%%
x = [16 -21 25 10];
y = [ 5 -38 16 10];

imshow ('brain2.jpg');
hold on

for i = 1:length (x)
    
plot (x(i),y(i),'g.','MarkerSize',16);
axis([-68 68 -102 70]);

end

figure

% imshow ('brain2.jpg');
hold on

for i = 1:length (x)
    
plot (x(i),y(i),'g.','MarkerSize',16);
axis([-68 68 -102 70]);
hold on
end

figure

imshow ('brain2.jpg');
hold on

for i = 1:length (x)
    
plot (x(i),y(i),'g.','MarkerSize',16);
% axis([-68 68 -102 70]);

end
%%

Subject: backround image to a graph

From: TideMan

Date: 14 Jul, 2009 07:40:26

Message: 2 of 5

On Jul 14, 6:26 pm, "recep mansiz" <aalmo...@hotmail.com> wrote:
> Hi all!!
>
> I want to put a backround image to my graph so the values can be seen on this image.
>
> I cannot fix the graph and photo correctly.  does anybody have any idea how to place the image correctly to tha graph??
>
> below I put three different implementation of the same code.
>
> %%
> x = [16  -21  25  10];
> y = [ 5  -38  16  10];
>
> imshow ('brain2.jpg');
> hold on
>
> for i = 1:length (x)
>
> plot (x(i),y(i),'g.','MarkerSize',16);
> axis([-68 68 -102 70]);
>
> end
>
> figure
>
> % imshow ('brain2.jpg');
> hold on
>
> for i = 1:length (x)
>
> plot (x(i),y(i),'g.','MarkerSize',16);
> axis([-68 68 -102 70]);
> hold on
> end
>
> figure
>
> imshow ('brain2.jpg');
> hold on
>
> for i = 1:length (x)
>
> plot (x(i),y(i),'g.','MarkerSize',16);
> % axis([-68 68 -102 70]);
>
> end
> %%

I do this all the time, but I don't have the Image Processing Toolbox,
and you don't need it for this.
Try this and report back:

c=imread('brain2.jpg');
figure;
image(c);
hold on
plot(x,y,'go',...
  'MarkerFaceColor','g')
set(gca,...
   'XLim',[-68 68],...
   'YLim',[-102 70])

Notes:
1. Try using image instead of imshow
2. You don't need a loop
3. Use filled circles instead of large dots.
4. Use handle graphics

Subject: backround image to a graph

From: recep mansiz

Date: 14 Jul, 2009 08:09:47

Message: 3 of 5


> I do this all the time, but I don't have the Image Processing Toolbox,
> and you don't need it for this.
> Try this and report back:
>
> c=imread('brain2.jpg');
> figure;
> image(c);
> hold on
> plot(x,y,'go',...
> 'MarkerFaceColor','g')
> set(gca,...
> 'XLim',[-68 68],...
> 'YLim',[-102 70])
>
> Notes:
> 1. Try using image instead of imshow
> 2. You don't need a loop
> 3. Use filled circles instead of large dots.
> 4. Use handle graphics

thanks for your reply tideman, the code greatly simplifies my job.

'brain2.jpg' is a 150x122 image. matlab places the image between [0 150 0 122] x-y boundaries. additionally, y axis increases through downward direction, thus +y direction stands at downward direction and -y stands at upward direction.
the problem is the image should have its origin at (0,0) and have x-y limits as you write at your code with y axis increasing at upwards direction.

is it possible to arrange the image like this??

thanks for your interest again.

Subject: backround image to a graph

From: TideMan

Date: 14 Jul, 2009 10:35:43

Message: 4 of 5

On Jul 14, 8:09 pm, "recep mansiz" <aalmo...@hotmail.com> wrote:
> > I do this all the time, but I don't have the Image Processing Toolbox,
> > and you don't need it for this.
> > Try this and report back:
>
> > c=imread('brain2.jpg');
> > figure;
> > image(c);
> > hold on
> > plot(x,y,'go',...
> >   'MarkerFaceColor','g')
> > set(gca,...
> >    'XLim',[-68 68],...
> >    'YLim',[-102 70])
>
> > Notes:
> > 1. Try using image instead of imshow
> > 2. You don't need a loop
> > 3. Use filled circles instead of large dots.
> > 4. Use handle graphics
>
> thanks for your reply tideman, the code greatly simplifies my job.
>
> 'brain2.jpg' is a 150x122 image. matlab places the image between [0 150 0 122] x-y boundaries. additionally, y axis increases through downward direction, thus +y direction stands at downward direction and -y stands at upward direction.
> the problem is the image should have its origin at (0,0) and have x-y limits as you write at your code with y axis increasing at upwards direction.
>
> is it possible to arrange the image like this??
>
> thanks for your interest again.

I think you need to look at it the other way around.
Consider the image as fixed and the overplot of the data as being
adjustable/configurable.

Subject: backround image to a graph

From: recep mansiz

Date: 14 Jul, 2009 10:50:03

Message: 5 of 5

> I think you need to look at it the other way around.
> Consider the image as fixed and the overplot of the data as being
> adjustable/configurable.

I made so, but the axis values are not desired ones. I wonder if I can change the axis values by renaming or with any other tricky way??

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
remove axis Sprinceana 16 Jul, 2009 08:26:01
axis recep mansiz 14 Jul, 2009 02:29:03
imshow recep mansiz 14 Jul, 2009 02:29:02
rssFeed for this Thread

Contact us at files@mathworks.com