how to fully whiten the white parts and fully blacken the black parts of a scanned image without changing its colorful parts
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a scanned image of a word(.docx) file. I want it to look like the original file. for this, i want to remove the noise i.e. fully whiten its white parts and fully blacken its black parts without changing its colorful parts.
4 Commenti
Walter Roberson
il 3 Nov 2018
Please tell us exactly where the boundary is between "black" (black) and "very dark blue" (color)?
Is (255,254,254) white or is it color?
You want color to be preserved, so you need to define for us when exactly a pixel is to be considered black or white or when exactly it is to be considered color.
Is your input grayscale? If so then imbinarize()
Risposte (1)
Image Analyst
il 3 Nov 2018
Convert the image from RGB to HSV with rgb2hsv().
hsvImage = rgb2hsv(rgbImage);
hImage = hsvImage(:, :, 1);
sImage = hsvImage(:, :, 2);
vImage = hsvImage(:, :, 3);
Then create two masks by thresholding the value and saturation channel.
blackMask = sImage < 0.3 * vImage < 0.5; (or maybe 128 instead of 0.5??)
whiteMask = sImage < 0.3 * vImage > 0.5; (or maybe 128 instead of 0.5??)
Then use those masks to assign the vImage to 0 or 1 (or maybe 255):
vImage(blackMask) = 0;
vImage(whiteMask) = 1;
% Finally recombine and convert back to RGB
hsvImage = cat(3, hImage, sImage, vImage);
rgbImage = hsv2rgb(hsvImage);
If you still need help, show your adapted code and attach your image.
1 Commento
Image Analyst
il 4 Nov 2018
Abdullah, are you still there?
You could also try using the Color Thresholder App on the Apps tab of the tool ribbon to determine threshold settings for the different color channels.
Of course you will need to have a flat background in order to use global thresholds, so if you need to flatten your background, to that first (demo attached).
Again, if you still need help, show your adapted code and attach your image.
Vedere anche
Categorie
Scopri di più su Audio and Video Data 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!