please, how can I divide an image into 2 vertical parts from the colomn number 145?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
%%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)]);
0 commentaires
Réponse acceptée
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
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);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!