Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Matlab multilevel array data removal based on value

1 Ansicht (letzte 30 Tage)
Shayne O'Brien
Shayne O'Brien am 17 Jun. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
I have a 1152x1324x3 uint8 array comprised of RGB values (the interval for all values is [0,255] for each of the three levels). A sample of the data is listed below:
ans(:,:,1) =
*0* 132 132 140 140 169 169 120 120 126 126
*0 0 0 0 0* 114 114 147 147 134 134
*0 0 0 0 0* 114 114 147 147 134 134
ans(:,:,2) =
*0* 118 118 125 125 161 161 120 120 130 130
*0 0 0 0 0* 110 110 141 141 128 128
*0 0 0 0 0* 110 110 141 141 128 128
ans(:,:,3) =
*0* 94 94 100 100 137 137 73 73 82 82
*0 0 0 0 0* 79 79 86 86 71 71
*0 0 0 0 0* 79 79 86 86 71 71
I would like to scan the data and remove all entries in which the value for all three levels is 0. The entries which are bolded (have *s around them) are examples of the entries that I would like removed completely. How would I do this?
  1 Kommentar
Image Analyst
Image Analyst am 17 Jun. 2015
Keeping in mind that images must remain rectangular, what does "remove" mean to you? You can't have images with 10 columns in row 1 and 6 columns in rows 2 and 3. There has to be some value there. Why don't you just step back and give us the overall big picture (no pun intended). You can't "remove" pixels, but what do you really want to accomplish? Do you want to find regions of a certain color, or what????

Antworten (1)

Andrew Schenk
Andrew Schenk am 18 Jun. 2015
Bearbeitet: Andrew Schenk am 18 Jun. 2015
The comment by Image Analyst is correct, every pixel location in an image must have some RGB value, so you cannot remove them per se.
However, to find which (i,j) locations are 0 in all three levels, you can use the MATLAB code below. This will return a logical 1152x1324 matrix in your case with 1's in the locations where the three level values are all 0.
all(~YourMatrix, 3)

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by