How can I divide a binary image horizontally?

1 visualización (últimos 30 días)
Nixon Dhar
Nixon Dhar el 1 de En. de 2018
Comentada: Nixon Dhar el 3 de En. de 2018
How can I divide a binary image horizontally?

Respuesta aceptada

Image Analyst
Image Analyst el 1 de En. de 2018
Decide on the column you want to split it at. Then:
leftPart = binaryImage(:, 1:column);
rightPart = binaryImage(:, column+1:end);
  3 comentarios
Image Analyst
Image Analyst el 2 de En. de 2018
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 el 3 de En. de 2018
Thanks a lot.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Geometric Transformation and Image Registration en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by