How to segment black pixels from a colour image?
    5 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
I have a colour image. From this image I have to remove the black circles and black symbols from it. How can I do it?

0 Kommentare
Antworten (2)
  DGM
      
      
 am 30 Apr. 2023
        
      Bearbeitet: DGM
      
      
 am 30 Apr. 2023
  
      If you want to clean up that image, start by deleting it and getting the original image before it was reduced to a microscopic JPG pixel salad.
% read the garbage image
inpict = imread('if_you_want_to_ruin_your_image_save_it_as.jpeg');
% 75% of chroma information has been discarded
% so H, S are mostly useless for any task selecting small features
% just use luma alone to select the region
mask = rgb2gray(inpict)<110;
% get rid of single-pixel speckles
mask = bwareaopen(mask,2);
% show the mask
imshow(mask,'border','tight')
% inpaint the masked region
outpict = inpict;
for c = 1:size(inpict,3)
    outpict(:,:,c) = regionfill(inpict(:,:,c),mask);
end
% show the image
imshow(outpict,'border','tight')
But wait! Now there's a 10px-wide halo of garbage all around where the black lines were!  Surprise!  Those were there to begin with.  
So what are the lessons?  
- If you can create a mask to define a region of an image that you want to inpaint based on its immediate surroundings, you can use regionfill().
- Don't save images as JPG unless you understand the amount of information you're throwing away. Generally, don't use JPG for any technical purposes where images need to be reprocessed.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




