Best data type for image in order to remove pixels and apply nanmean?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I wish to remove outlier pixels from an image before calculating the mean values of each of the R,G and B channels. Therefore i set the R,G,B values of the outlier pixels to NaN('double'), in order to apply the nanmean function. But my code doesn't work unless i transform my image matrix to the data type double ( or else the NaN values will be considered as 0 and the mean wouldn't be correct). My problem is that the newly adjusted image doesn't have the same colors as the original one, and it only shows gray and black(for the removed pixels). I even tried reconverting the matrix to uint8 but it still didn't work. Any suggestions?
0 comentarios
Respuestas (1)
Image Analyst
el 29 de Jul. de 2018
You cannot remove outlier pixels because your image must remain rectangular. OK, so you identify them somehow, and then set them to NaN. That is not removing them. Then you try to take the mean of something -- of the whole image? of individual color channels? -- I have no idea.
Then you say "But my code doesn't work". But what code? The code to identify the outlier pixels? The code to compute the means? Some code AFTER you compute the means? I have no idea.
Then you say "...the newly adjusted image doesn't have the same colors...", but you didn't say how this adjustment was done. Did you set the NaN pixels to the overall mean, or the mean of each respective color channel? Again, no idea.
Anyway, if you "adjusted" the image pixels, then why SHOULD they have the same color as the original? You adjusted them somehow so of course they won't.
Finally, you say "...it only shows gray and black(for the removed pixels)...". Well again, you can't remove pixels unless you want to just get a 1-D list (vector) of all the pixels values. You can't remove them and keep it a 2-D RGB image. All you can do is to change their values.
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!