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 Center および File ExchangeGeometric 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