how to crop the red region in an image
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dina Ragab
il 11 Giu 2017
Risposto: Image Analyst
il 11 Giu 2017
I have a mammogram image and in it a red contour, the rgb channels across this contour are changed whereas they are constant all over the other regions. I want to do a for loop to search about this region in the image and crop it. Can anyone help?
0 Commenti
Risposta accettata
Image Analyst
il 11 Giu 2017
I'm guessing that it's a mammogram that's had computer graphics (red pixels) burned into the image. To find the pure red pixels, you need to find where the red signal is 255 or 65535, depending on whether it's uint8 or uint16, and the green and blue signals are 0. See this snippet:
% Find pure red pixels, pure green pixels, and pure blue pixels.
maxValue = intmax(class(rgbImage))
pureRedPixels = (redChannel == maxValue) & (greenChannel == 0) & (blueChannel == 0);
pureGreenPixels = (redChannel == 0) & (greenChannel == maxValue) & (blueChannel == 0);
pureBluePixels = (redChannel == 0) & (greenChannel == 0) & (blueChannel == maxValue);
Use the one for red pixels and then call imshow() to see them. If you don't see anything then use
pureRedPixels = (redChannel <= 0.8*maxValue) & (greenChannel == 0) & (blueChannel == 0);
Keep lowering the 0.8 until you start to see something. I'm not sure exactly what color your red is. The initial code assumes red is (255,0,0) or (65535,0,0).
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Image Processing and Computer Vision in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!