Effacer les filtres
Effacer les filtres

how can i change th color of pixels in an image

1 vue (au cours des 30 derniers jours)
paramveer sran
paramveer sran le 1 Août 2016
Modifié(e) : Guillaume le 1 Août 2016
this is an image. i want to change the color of every pixel to white(except background).how can i do?i googled it what could not do this.

Réponses (2)

Walter Roberson
Walter Roberson le 1 Août 2016
new_image = double(input_grayscale_image > 0);
  1 commentaire
paramveer sran
paramveer sran le 1 Août 2016
i have tried this.it gives this output (attched image)

Connectez-vous pour commenter.


Guillaume
Guillaume le 1 Août 2016
Modifié(e) : Guillaume le 1 Août 2016
Note: never use the jpg format for image processing and for images with uniform colours such as yours. JPG is a lossy (normally) compression format that does not cope well with uniform areas. You can see that your original image has lots of compression artifacts. I recommend you use PNG as a format.
The black in your image is not truly black. It's mostly 1 instead of 0, but because of the compression artifacts near the transition to the grey, it sometimes goes higher. You just need to find the right threshold
You can either do the thresholding explicitly:
new_image = your_image(:, :, 1) > 20 %replace 20 by whichever threshold you prefer, from 0 to 255
Or use im2bw:
new_image = im2bw(your_image, 0.1) %replace 0.1 by whichever threshold you prefer, from 0 to 1

Catégories

En savoir plus sur Image Segmentation and Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by