Embed cropped image within original image using 'drawpoint'
Show older comments
I want to display a scaled up user-defined region of interest (ROI) within the original image. The issue:

The code:
clc, clear, close all
% select zoomed in ROI
firstFrame = imread('tiger_test.jpg');
imshow(firstFrame);
title('Select zoom region:','FontSize',16);
zoom = drawrectangle('Color',[1 1 0]);
zoomRegion = zoom.Position;
close all
% decide where to put it
imshow(firstFrame);
title('Click where (LH corner) to put it:','FontSize',16);
poop = drawpoint;
x_inset = round(poop.Position(1));
y_inset = round(poop.Position(2));
close all
% test it: overlay the two images
cropped = imcrop(firstFrame,zoomRegion);
newFrame = imresize(cropped,2); % scale up by 1.5x
newFrame_dim = size(newFrame);
x_w = newFrame_dim(1);
y_w = newFrame_dim(2);
firstFrame(x_inset:(x_inset+x_w-1),y_inset:(y_inset+y_w-1),:) = newFrame;
figure
imshow(firstFrame);
drawnow;
Accepted Answer
More Answers (0)
Categories
Find more on Geometric Transformation and Image Registration 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!