I have an image from which I want to crop a certain portion of it. I drew the boundary at first. Below is the code:
img = imread('Intensity1.jpg');figure, imshow(img);% getting a segment
h=drawfreehand();position = wait(h);region=uint8(roipoly(img,position(:,1),position(:,2)));region=region.*img;figure,imshow(region); title('Segmented Region');% use bwperim rather than bwboundaries to get an Image of boundary.
boundImg = uint8(bwperim(rgb2gray(region),4));boundImg(boundImg ~=0) = max(img(:));figure, imshow(img + boundImg)% save image without loosing information..
imwrite(img + boundImg, 'writeImg.jpg');% check
read = imread('writeImg.jpg');figure, imshow(read)isequal(read, img + boundImg)
The image is below:
I want to crop the portion of the image specified by the boundary above. I tried the following line of code but there is no change in the result.
imcrop('Intensity1.jpg');
Any suggestions would be very much appreciated. Thank you.
Best Answer