please, how can I divide an image into 2 vertical parts from the colomn number 145?

12 vues (au cours des 30 derniers jours)
%%it gives me the horizontal division nand I want the vertical one from a known colomn, [r, c] = size(binB); topHalf = imcrop(binB, [1, 2, r, floor(c/2)]); bottomHalf = imcrop(binB, [2, ceil(c/2), r, floor(c/2)]);

Réponse acceptée

Image Analyst
Image Analyst le 2 Mar 2017
First of all, your third parameter is supposed to be the width in columns, and the fourth parameter is supposed to be the height in rows. You have them switched.
Try it this way (using indexing) instead:
[rows, columns] = size(binB);
middleRow = floor(rows/2);
topHalf = binB(1:middleRow, :);
bottomHalf = binB(middleRow+1:end, :);
  3 commentaires
Image Analyst
Image Analyst le 3 Mar 2017
Well I don't know what you mean. It divides it vertically so that you have two short and wide shapes - the top half and the bottom half. If you really want the left half and the right half, just switch the indexes. You know that the first index is the row and the second is the column, right? So just do
[rows, columns] = size(binB);
middleCol = floor(columns/2);
leftHalf = binB(:, 1:middleCol);
rightHalf = binB(:, middleCol+1:end);
Abdou dgm
Abdou dgm le 3 Mar 2017
I'm a beginer with matlab, but now is working, thank you sir for your help %

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing 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