[Scilab-users] ?==?utf-8?q? Put an image as the background of an axis

Antoine Monmayrant amonmayr at laas.fr
Tue Feb 9 08:04:09 CET 2016


 
Le Mardi 9 Février 2016 00:04 CET, Philipp Mühlmann <p.muehlmann at gmail.com> a écrit: 
 
> Well, as I understand you want to plot a function over an background image.
> 
> In the case the image pixel number fits the X-Y range of your graph it's
> rather simple.

Well, it is, unless IPD does not work on your system, which is my case!
None, absolutely none of the image processing toolboxes work on my machine.
And it's not only my machine, it's the case for most of the machines we have at work.
So I cannot rely on an image processing toolbox to achieve what I want and I have to rely on base functions.

Thanks anyway for you help,

Antoine

> 
> img = ReadImage(IPD_PATH + 'demos\teaset.png');
> rows = size(img,'r');cols = size(img,'c');
> img(rows,1,:) = (0);        // changing left lower image corner for
> checking purpose
>                                         // change all 3 colour
> channels to get a black pixel
> ShowColorImage(img,'');
> a = gca();a.axes_visible = ["on","on","off"];x = linspace(1,600,600);y
> = 1/2*(x);plot(x,y,'-');a.data_bounds = [0,0;cols,rows];
> 
> Two tricky things though:
> 
> 1st: image coordinates (center of pixel) start at "1", hence there is a gap
> of 0.5 between image borders and the axes
> 
> 2nd: it might become tricky if you want to have negative values on the axis.
> 
> Probably there is a way to shift the image to other position within the
> coordinate system?
> 
> 
> So....not sure if this helps your purpose.
> 
> You could also switch "ON" / "OFF" the background image by access the
> children of the figure, such as:
> 
> IMGPlot = a.Children(2);   // children(2) is the background in this
> caseIMGPlot.visible = 'off';
> 
> 
> A complete other way would be to combine two images of same size.
> Say...background image is img1.
> 
> your plot = img2.
> Plot the graph and save the figure as a temporary image.
> 
> load img1
> load temporary image
> 
> If size (img1) == size(img2)....You could use SIVP module to linear combine
> two images:
> 
> img_gray = double(RGB2Gray(img));img2 = zeros(rows, cols) +
> 255;img2(rows/2,:) = 0;img3 = imlincomb( 0.5, img_gray, 0.4, img2)
> // the values here define some kind of transparency.figure();
> ShowImage(img3,'');
> 
> 
> 
> Best regards,
> Philipp
> 
> 
> 
> 
> 2016-02-08 17:49 GMT+01:00 Jan Åge Langeland <j-lan at online.no>:
> 
> >
> >
> > On 08.02.2016 11:47, antoine.monmayrant at laas.fr wrote:
> >
> > Hi everyone,
> >
> > I just failed at placing an image behind a plot.
> > I thought that would be easy:
> >     - create a figure
> >     - create an image uicontrol
> >     - create an axis
> >     - plot in the axis
> >     - set axis.filled="off"
> >
> > Apparently I was wrong.
> > I did not find a way to overlap a plot with transparent background over my
> > image.
> > It seems that the image is always above the plot no matter what order the
> > uicontrol/axes where created.
> > I also tried to put both of them inside the same frame, but I did not work
> > either.
> >
> > Any idea?
> >
> >
> >
> > ShowImage(im,'J2');
> >
> > b=newaxes();
> > b.filled = "off";
> >  plot(a)
> >
> > JÅ
> >
> > _______________________________________________
> > users mailing list
> > users at lists.scilab.org
> > http://lists.scilab.org/mailman/listinfo/users
> >
> >
> >
> > _______________________________________________
> > users mailing list
> > users at lists.scilab.org
> > http://lists.scilab.org/mailman/listinfo/users
> >
> >
> 
> 
> -- 
> There we have the salad.
 
 
 
 





More information about the users mailing list