Automatically crop the edge detected area of an image

11 views (last 30 days)
after detect the edge by canny edge edge detector how can i crop the edge detected area of the image?
  1 Comment
SHOBA MOHAN
SHOBA MOHAN on 21 Dec 2017
Hi, Please refer this link, it will be helpful for you. https://www.mathworks.com/matlabcentral/answers/337751-crop-the-irrelevant-part-of-the-image?s_tid=answers_rc1-2_p2_MLT

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 21 Dec 2017
Try imcrop(). I can't say more than that because you forgot to attach your image.
  5 Comments
Image Analyst
Image Analyst on 22 Dec 2017
Your badly-named edge is an image, not a bounding box. Don't call your image edge since that's a built-in function. You can call bwconvhull() to get a single blob from all the edges and then use regionprops(binaryImage, 'BoundingBox') to find the bounding box that you can then pass in to imcrop(). Write back if you have trouble.
Kogila wanee
Kogila wanee on 11 Jan 2018
thank you sir, i tried that, but if the background white/no illuminations then i can crop it , but if the image have the illuminations (light effect) then i cant crop it , it crop the entire image?
how can i remove those illuminations??
Here is my code..........
clc;
clear all;
close all;
[inputfilename,dirname] = uigetfile('*.*');
inputfilename = [dirname, inputfilename];
Image = imread(inputfilename);
hsvImage = rgb2hsv(Image);
sImage = hsvImage(:, :, 2);
mask = sImage > 0.1;
mask = bwareafilt(mask,1);
mask = imfill(mask, 'holes');
props = regionprops(logical(mask), 'BoundingBox');
croppedImage = imcrop(rgbImage, props.BoundingBox);
figure,imshow(croppedImage);title('Cropped Image');

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!