Region of Interest Image Processing

Hello All
I want to apply some algorithm only on region of interest in an input image.
Let say I have an image A.
image_A=imread('1.jpg'); "size is 576x576"
[rows cols colors]=size(image_A);
image_interest=zeros(rows,cols,colors);
new_image=imcrop(image_A);"this crops only interested region lets say I am cropped the lower region from image_A".
"Now I want this region size as same as image_A" for further processing.
Let say I wan to subtract these two images. like
dist=abs(image_A-new_image)..
can any one help...

 Accepted Answer

Use imresize() to stretch the lower half image up to the size of the original image_A:
new_image = imresize(new_image, size(image_A));

6 Comments

Thanks. What about video sequence. do I need to redefine ROI in every frame for writing?
Yes. As far as I know all frames in a single video file must be the same size.
Yeah, but upper half region is also processing I only need the distance at specific ROI.As I define ROI I want to subtract only that ROI from original image.
I don't know what you mean when you mention distance. Distance between what and what?
I thought it was strange when you wanted to take the lower half of the image and then make it the same size as the original image. Why would you want to do this?
I want to detect abondoned object on the ground that's why I define ROI fro image.if the ROI is not same size then I cannot perform subtraction.is there any way to do that by only considering the ROI.
Then you just extract the bottom half of the images. You don't resize anything.
backgroundBottomHalf = double(backgroundImage(rows/2:end, :));
oneFrameBottomHalf = double(thisFrame(rows/2:end, :));
difference = abs(oneFrameBottomHalf - backgroundBottomHalf);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!