![untitled.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/269345/untitled.png)
extraction of part of image
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Smruti Khobragade
le 28 Jan 2020
Réponse apportée : Subhadeep Koley
le 1 Fév 2020
hello,
i want to extract some part of original image bsed of pixel values. for example i want to extract part which have pixel values greater than 200 and other part to be blackened .i dont wanna use im crop bcoz the part i want to extract should depend on pixel values.
0 commentaires
Réponse acceptée
Subhadeep Koley
le 1 Fév 2020
Hi Smruti, the below code might help as you want "to extract the part of original image based on pixel values the output will be same image with threshold 200 and other blacken".
img = imread('peppers.png');
[r, c, b] = size(img);
th_img = uint8(zeros(r,c,b));
th = 100; % Put your threshold here
for i = 1:r
for j = 1:c
if img(i, j, :) > th
th_img(i, j, :) = img(i, j, :);
end
end
end
figure, imshowpair(img, th_img, 'montage');
![untitled.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/269345/untitled.png)
0 commentaires
Voir également
Catégories
En savoir plus sur Get Started with Image Processing Toolbox 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!