Crop the irrelevant part of the Image
Show older comments
I am new to Matlab. I want to crop the highlighted part of the gray image and remove the rest part. How to do that, kindly explain as well. Thanks.

3 Comments
Zaheer Abbas
on 28 Apr 2017
Zaheer Abbas
on 2 May 2017
Image Analyst
on 2 May 2017
You have not attached the original image. Not the cropped one, and not the one with the red box on it, but the original image. So, did you even try stdfilt()?
Accepted Answer
More Answers (2)
doc imcrop
When propted, draw a rectangle in your interested area.
I = imread('your image') ; % Read image
imshow(I) ;
I1 = imcrop(I) ; % crop the image
imshow(I1)
imwrite(I1,'croppedimage.jpg'); % save the image
5 Comments
Zaheer Abbas
on 28 Apr 2017
KSSV
on 28 Apr 2017
You can input parameters or you can drag a rectangle on your required area. Run the above code, when image opens draw/ drag a rectangle. Your highlighted image will be saved on the name croppedimage.jpg
Zaheer Abbas
on 28 Apr 2017
Edited: Zaheer Abbas
on 28 Apr 2017
KSSV
on 28 Apr 2017
How about picking up half of the matrix after imread?
Zaheer Abbas
on 29 Apr 2017
Image Analyst
on 2 May 2017
0 votes
Zaheer, I'm sure by now you've tried to take my suggestion and use stdfilt() to automatically get the bounding box. You can look at how I did it and compare it to your own.

Categories
Find more on Image Preview and Device Configuration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!