0
votes

I've got 10 grayscale images. I'd like to plot a simple YELLOW line over each image separately, then show them all over one plot (montage style).

I tried to draw all images first, but that made plotting lines very tricky (X,Y axes weren't standard for plotting over each separate image).

I thought about burning the line over the image, but I don't have the computer vision toolkit (easy functions to do this), otherwise it seemed complicated to both convert the grayscale to color and get it to burn the image.

I thought I might be able to use the function newplot to create a temporary plot space for each image, draw the line with a simple plot(...) call, then save it and just montage(...) all the individual plots at the end.

Is this possible? I've never played with the function newplot or tried to loop through individual plots, saving them up for a call to montage(...) this way, but it seems like a logical/simple approach.

1
I'm having a hard time visualizing this. Where do you want to draw this line in each image? Can you show a pictorial example at all? Also, you can use line to draw a line in a figure window. You just need to be aware that the y axis is positive y-down when showing an image with imshow.rayryeng

1 Answers

0
votes

I finally worked it out with subplot, subimage, and plot, using subplot with the position arguments does what I want easily enough. Using subplot kept the axis relative to the subplot I was on so I could plot the line with a standard fplot/plot call. The trick was normalizing the position to percentages vs. thinking of it in terms of pixels.

here's some code demoing it:

      % Loop through this code, each time moving the subplot by position
      LOOP {
        % calculate left & bottom position as percentages (0..1)
        subplot( 'Position', [ left bottom (1/cols) (1/rows) ] );
        hold on

        % (1) Draw the image
        subimage(tmpImg, [0 255]);
        axis off;

        % (2) Plot the line over the original image
        F = @(x) polyval(p, x);
        fplot(F, [1 dimX 1 dimY], '-y');
      }