need help: high resolution image motion

1 view (last 30 days)
I have a high resolution tiff image of size [9867 18533], gray scale image (178 MB). I have read it using imread, while displaying full image is displayed reducing the size to 4%. Warning: Image is too big to fit on screen; displaying at 4% . I want full image to be displayed matching with the screen size. So a portion of it only to be displayed, for example if screen size is 1280 X 1024, I want only that portion (based on coordinates I select as starting point) of the entire image to be displayed, and from that point I want image to move slowly, every 20 msces (50 Hz refresh rate screen) such a way that from the display we can derive velocity using optical flow. When new pixels of image is displayed the old pixels at the borders should go out automatically. It should imitate like a image in motion. How to do this using matlab?

Accepted Answer

Walter Roberson
Walter Roberson on 25 Dec 2015
Instead of using imshow(), use image() together with an axes Position as large as feasible and "axis image" (so DataAspectRatio becomes [1 1]). Control which portion of the image is seen by setting the axis XLim and YLim. You can set up a timer object to change the XLim and YLim (and then do a drawnow() )
I am not sure what the connection is to optical flow, unless you are wanting the displayed image to also become data for the optical flow tracking routines. If so then you would use indexing to select a portion of the image (imcrop could also be used but it gets down to using indexing so you might as well avoid the overhead.)
  5 Comments
geoleo Space
geoleo Space on 25 Dec 2015
Dear sir, image was not showing picture like imshow, image was showing some colored (red) image, whereas my image is greyscale. Dear Walter sir, can you elaborate your answer with an example code. So that I can do accordingly?
Walter Roberson
Walter Roberson on 25 Dec 2015
If the image is grayscale then use
colormap(gray(256))
after using image()
Sample code:
imwide = size(YourImage, 2);
imhigh = size(YourImage, 1);
fig = figure('Units','normal','Position', [0 0 1 1]);
ax = axes('Units', 'normal', 'Position', [0 0 1 1], 'Parent', fig, 'Visible', 'off');
axis(ax, 'image', 'tight');
set(ax, 'Units', 'Pixel');
axpos = get(ax, 'Position');
axwide = axpos(3);
axhigh = axpos(4);
imh = image(ax, YourImage);
leftx = 1;
boty = 1;
rightx = leftx + axwide - 1;
topy = boty + axhigh - 1;
set(ax, 'XLim', [leftx rightx], 'YLim', [boty topy]);
initialize_optical_flow(ax);
flow_slice = YourImage(leftx:rightx, boty:topy);
update_optical_flow(ax, flow_slice);
drawnow();
for K = 1 : 100
start_time = tic();
newx = round(min(max(leftx + 5*randn() + 1, 1), axwide-imwide));
newy = round(min(max(boty + 5*randn() + 1, 1), axhigh-imhigh));
leftx = newx;
boty = newy;
rightx = leftx + axwide - 1;
topy = boty + axhigh - 1;
set(ax, 'XLim', [leftx rightx], 'YLim', [boty topy]);
flow_slice = YourImage(leftx:rightx, boty:topy);
update_optical_flow(ax, flow_slice);
finish_time = toc(start_time);
pause( 1/50 - finish_time ); %trigger draw, aim for 50 Hz
end
The +1 in the newx and newy is there to bias the motion towards the right and up, because randn() is symmetric around 0. I choose randn() instead of rand() to illustrate that the motion need not be forward motion.
You would need to supply the initialize_optical_flow() and update_optical_flow() routine. I passed in the axes in case you want the optical flow routine to draw on it.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 25 Dec 2015
You can use a scroll panel. See the attached zooming demo given to me by the Mathworks to illustrate this capability.
  2 Comments
geoleo Space
geoleo Space on 25 Dec 2015
Edited: geoleo Space on 25 Dec 2015
Dear Sir, thank you I will go through this code. I have a single image, that I have to move from one end to other. so that a camera kept in front of it, feels that the image surface is in motion. With single image I should move from one end to another, such that it appears like a video. When a camera captures the scenes, it gets some overlap between previous image and next image with which it can compute optical flow. Is this possible using single image and matlab?
geoleo Space
geoleo Space on 25 Dec 2015
Dear Sir, I have seen the code, and executed. I want the image to fill full screen. for proper simulation. I think thats not happening right? And it should move from one end to another, I should be able to define the way the image should move.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!