how to crop a interest part image

1 vue (au cours des 30 derniers jours)
guitoune mohieddine
guitoune mohieddine le 11 Avr 2015
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 .

Réponse acceptée

Image Analyst
Image Analyst le 11 Avr 2015
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 commentaires
Image Analyst
Image Analyst le 12 Avr 2015
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 le 12 Avr 2015
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

Connectez-vous pour commenter.

Plus de réponses (1)

guitoune mohieddine
guitoune mohieddine le 12 Avr 2015
Modifié(e) : guitoune mohieddine le 12 Avr 2015
thank you , it works

Catégories

En savoir plus sur Geometric Transformation and Image Registration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by