Cut an area in binary Image

조회 수: 7 (최근 30일)
Nour
Nour 2014년 12월 21일
댓글: Image Analyst 2015년 2월 14일
Hi Everybody, Please, I would like to cut the white pixels area from a binary image, so that the output will be this white area. From another question, I see a method that shows how to surround this area, but also I would like to cut automatically the part surrounded, which is a vehicle logo in my case. Here is the link to this method: http://www.mathworks.com/matlabcentral/answers/24041-cut-an-image
I've tried this method for some hours, and trying to edit it to see the results, but until now I even didnt get the surrounded line, please your help is welcome.
Thanks!
Nour.
  댓글 수: 1
Nour
Nour 2014년 12월 21일
편집: Nour 2014년 12월 21일
Here is what I expect as output

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

채택된 답변

Image Analyst
Image Analyst 2014년 12월 21일
There are several ways to crop the image. For example you can use regionprops() to find the bounding box, like I show in my Image Segmentation Tutorial http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862.
Or you could simply find the min and max rows and columns:
[rows, columns] = find(binaryImage);
topRow = min(rows);
bottomRow = max(rows);
leftColumn = min(columns);
rightColumn = max(columns);
croppedImage = binaryImage(topRow:bottomRow, leftColumn:rightColumn);
You could also find the bounding box by summing vertically and horizontally and then using find() like above.
  댓글 수: 14
Nour
Nour 2015년 2월 14일
Hi, I've tried export_fig() few days ago, but I got some errors, actually I think I don't understand how to use it, please if you can help me with that.
Which File Exchange?
Thanks!
Image Analyst
Image Analyst 2015년 2월 14일
You can contact him at his web site with any error messages: http://undocumentedmatlab.com/blog/export_fig

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by