how to crop a interest part image

조회 수: 1 (최근 30일)
guitoune mohieddine
guitoune mohieddine 2015년 4월 11일
편집: guitoune mohieddine 2015년 4월 12일
hellow
I have this image i segmented by kmeans méthod, and i get this résult
Now i want to crop it to get just the license plate
, so there is a solution ???
please help me .

채택된 답변

Image Analyst
Image Analyst 2015년 4월 11일
Just get profiles and use find:
verticalProfile = sum(binaryImage, 2); % Sum along columns in each row.
row1 = find(verticalProfile, 1, 'first');
row2 = find(verticalProfile, 1, 'last');
horizontalProfile = sum(binaryImage, 1); % Sum along rows in each column.
column1 = find(horizontalProfile, 1, 'first');
column2 = find(horizontalProfile, 1, 'last');
croppedImage = binaryImage(row1:row2, column1:column2);
  댓글 수: 4
Image Analyst
Image Analyst 2015년 4월 12일
guitone's "Answer" moved here:
Thank you for reply, but there is an error:
Index exceeds matrix dimensions.
Error in test (line 51)
greenChannel = rgbImage(:, :, 2)
Can you help me?
Image Analyst
Image Analyst 2015년 4월 12일
You're obviously not using the image that you posted and gave to me. The image you posted is a color image, but the one you're using is a grayscale image. So you need to put this code after your call to imread():
if numberOfColorBands >= 3
% Crop the image
rgbImage = rgbImage(50:400, 100:600, :);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Crop the image
grayImage = redChannel;
else
% It's already gray scale.
% Crop the image
grayImage = rgbImage(50:400, 100:600, :);
end

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

guitoune mohieddine
guitoune mohieddine 2015년 4월 12일
편집: guitoune mohieddine 2015년 4월 12일
thank you , it works

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by