フィルターのクリア

How to change selected pixels color value to 0?

3 ビュー (過去 30 日間)
Simaa
Simaa 2022 年 8 月 28 日
回答済み: Chunru 2022 年 8 月 29 日
Hello,
I need to select pixels interactively from the image and change values to 0.
[filename, pathname] = uigetfile({'*.*';'*.bmp';'*.png';'*.jpg';'*.gif'}, 'Pasirinkite faila');
Image = imread([pathname,filename]);
pval=impixel(Image);
This way I can see selected pixels values:
pval =
231 71 115
207 0 70
249 12 84
115 32 42
How can I change those exact values to zero?
The point is to change selected color to black.
Thanks for your help!

採用された回答

Chunru
Chunru 2022 年 8 月 29 日
% Get an indexed image
Im = imread("peppers.png");
[Im, cmap] = rgb2ind(Im, 256);
%whos
Name Size Bytes Class Attributes Im 384x512 196608 uint8 cmap 256x3 6144 double cmdout 1x33 66 char
pval = [
231 71 115
207 0 70
249 12 84
115 32 42];
for i=1:numel(pval)
Im(Im==pval(i)) = 0;
end
imshow(Im, cmap)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by