Filter löschen
Filter löschen

How can I make automatic crop?

1 Ansicht (letzte 30 Tage)
wisam kh
wisam kh am 24 Jun. 2018
Kommentiert: wisam kh am 25 Jun. 2018
Hello
How can I make automatic crop around core? like
.
  2 Kommentare
Rik
Rik am 24 Jun. 2018
Have a read here (or here for more general advice) and here. It will greatly improve your chances of getting an answer.
wisam kh
wisam kh am 24 Jun. 2018
Thank you

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 24 Jun. 2018
Why do you need to crop it?
Anyway, if you do for some reason, you can just binarize and look for the min and max row and column.
binaryImage = imbinarize(grayImage);
[rows, columns] = find(binaryImage);
row1 = min(rows);
row2 = max(rows);
col1 = min(columns);
col2 = max(columns);
croppedGrayImage = grayImage(row1:row2, col1:col2);
imshow(croppedImage);
  5 Kommentare
Image Analyst
Image Analyst am 24 Jun. 2018
Bearbeitet: Image Analyst am 24 Jun. 2018
Well there's the problem. You totally ignored my code in my answer, and did it your own (wrong) way. Why?
wisam kh
wisam kh am 25 Jun. 2018
I am sorry sir, I did not ignore your answer, but I tried it and did not succeed.
BW=im2bw(img,0.8);
[rows, columns] = find(BW);
row1 = min(rows);
row2 = max(rows);
col1 = min(columns);
col2 = max(columns);
croppedImage = img(row1:row2, col1:col2);
figure, imshow(croppedImage);title('crop Image');
but the problem was here: BW=im2bw(img,0.8);
that should be : BW=~im2bw(img,0.8);
Now the problem has been solved
am sorry
Thank you so much for your time and effort
I apologize to you again

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by