need help: high resolution image motion
1 view (last 30 days)
Show older comments
geoleo Space
on 25 Dec 2015
Commented: Walter Roberson
on 25 Dec 2015
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?
0 Comments
Accepted Answer
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
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.
More Answers (1)
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
See Also
Categories
Find more on Image and Video Ground Truth Labeling in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!