How can I divide a binary image horizontally?

조회 수: 1 (최근 30일)
Nixon Dhar
Nixon Dhar 2018년 1월 1일
댓글: Nixon Dhar 2018년 1월 3일
How can I divide a binary image horizontally?

채택된 답변

Image Analyst
Image Analyst 2018년 1월 1일
Decide on the column you want to split it at. Then:
leftPart = binaryImage(:, 1:column);
rightPart = binaryImage(:, column+1:end);
  댓글 수: 3
Image Analyst
Image Analyst 2018년 1월 2일
I hope you were able to figure out to switch the index, but since you haven't accepted yet, I'll assume not and I'll provide the code below. Assuming you know the top line of the license plate, and the bottom line, and can average those two to get the middle line, simply do this:
upperPart = binaryImage(1:middleRow, :);
lowerPart = binaryImage(middelRow+1:end, :);
Indexing tutorial:
In using indexes, when you say : (colon) by itself, it basically means "all" in whatever index it's at. So above here, it means "all columns" and in my first answer it meant "all rows".
Saying "end" is a shortcut to the last index, without ever having to figure out what it might be. So if binaryImage had 50 rows and 80 columns, binaryImage(20:end, 50:end) would be the lower right part of the image from row 20 to row 50 and column 50 to column 80.
When you use colon with two numbers/expressions on either side, it means go from the left expression to the right expression in steps of 1. So 1:50 would mean a vector [1,2,3,4,5,6,.......,49,50]. When it sees this, MATLAB uses all of those rows. So binaryImage(1:30, :) would mean all columns but only the top 30 rows of the image, whereas binaryImage(:, 60:end) would mean all rows but only from column 60 to the right edge of the image.
I hope that explains indexing and helps you understand and use it in the future.
Nixon Dhar
Nixon Dhar 2018년 1월 3일
Thanks a lot.

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

추가 답변 (0개)

카테고리

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