Scrambling the object of an image without altering its white background

1 visualización (últimos 30 días)
Brahm
Brahm el 6 de Sept. de 2017
Respondida: Image Analyst el 6 de Sept. de 2017
Hello,
I'm in a situation where I need to scramble the pixels of an object in an image, but not scramble the white pixels of its background to maintain the object's shape.
Scrambling images themselves has a lot of resources.
How can I avoid randomizing the pixels in the background?
Thank you

Respuestas (2)

Cam Salzberger
Cam Salzberger el 6 de Sept. de 2017
Hello Brahm,
I believe that if you have a binary mask indicating where the object is, you could simply extract the linear indices of the pixels of the object. Once you have that, you can use randperm to help you randomize those indices, and then simply reassign the values based on the new permutation.
If you're not sure how to extract the binary mask, check out imbinarize.
-Cam

Image Analyst
Image Analyst el 6 de Sept. de 2017
Cam's method is correct. I already have an example for a color image without a mask. I've attached it and you can adapt it however you want. If you need more specific help, then attach your image, but try it yourself first since it's not hard.

Community Treasure Hunt

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

Start Hunting!

Translated by