resize an image by deleting columns
Mostra commenti meno recenti
How are you everyone!
Today I have a binary image and I want to resize it by deleting columns which have zero values, for this purpose I can use this command
a(:,any(a))=[];
the problem with this command is that I want to leave just one zero-value column to keep regions separated. Could you help me to solve this problem
Thank you!
Risposta accettata
Più risposte (1)
Image Analyst
il 29 Mar 2016
Modificato: Image Analyst
il 29 Mar 2016
That does not do it. The help says for any(): "Determine if any array elements are nonzero" So any(a) will give any columns that have a non-zero in them. Then, if you delete those, all you'll be left with are the columns that are all 100% zero. Perhaps you want this:
a(:, ~any(a))=[]; % Delete any column with 1 or more zeros in it.
or this:
a(:, all(a))=[]; % Delete column if all elements in it are zero.
OK, now, I don't understand what "I want to leave just one zero-value column" means. What if you have 50 rows and 100 columns and columns 1, 4, and 6 have 23 zeros in them, and columns 40, 41, and 45 have 50 zeros (so they are zero in all rows)? Which columns do you want to delete, and where exactly do you want to insert an all-zero column as a separator?
1 Commento
majed majed
il 29 Mar 2016
Modificato: majed majed
il 29 Mar 2016
Categorie
Scopri di più su Read, Write, and Modify Image in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!