フィルターのクリア

how to assign zero value to all pixels in an image ?

9 ビュー (過去 30 日間)
sheno39
sheno39 2013 年 9 月 11 日
assign zero value to pixel

採用された回答

Jan
Jan 2013 年 9 月 11 日
It depends on what an "image" is. Please post more details in future questions. Fortunately the procedure to set the values to 1 is equal:
Img = rand(1024, 768, 3); % RGB image
Img(:) = 0;
Img2 = randi([0, 255], 1024, 768, 'uint8');
Img2(:) = 0;
  2 件のコメント
sheno39
sheno39 2013 年 9 月 11 日
thanks a lot. as am beginner in matlab programming, i do not how to do the code.. i need the code for following function: function computedensity() for x in all pixels p[x] = 0; for n in all pixels less than 3 p[x]+=exp(-(f[x]-f[n])^2
Jan
Jan 2013 年 9 月 12 日
編集済み: Jan 2013 年 9 月 12 日
This is a completely new question. Please ask it in a new thread.
"for n in all pixels less than 3 " is not clear to me. What is "f"?

サインインしてコメントする。

その他の回答 (2 件)

sidra
sidra 2013 年 9 月 11 日
I don't understand what purpose setting all the pixel values to zero would achieve.
Nevertheless One of the method is:
You can use two for loops starting from 1 to you image size and the within these loops set the pixel values to zero. Something of this sort
for i=1:n
for j=1:m
img(i,j)=0;
end
end
where n and m are the number of rows and columns respectively.
  2 件のコメント
sheno39
sheno39 2013 年 9 月 11 日
thanks for your answer.. how to code the following.. kindly reply.. function computedensity() for x in all pixels p[x] = 0; for n in all pixels less than 3 p[x]+=exp(-(f[x]-f[n])^2
Image Analyst
Image Analyst 2013 年 9 月 11 日
% Find all pixels < 3
binaryImage = f < 3; % binaryImage is what you called x
Now, what's f(n)? What is n? In f(x), x is all pixels less than 3. But what is n in f(n)?

サインインしてコメントする。


Image Analyst
Image Analyst 2013 年 9 月 11 日
Yet another way
grayImage = zeros(size(grayImage), 'uint8');
  1 件のコメント
sheno39
sheno39 2013 年 9 月 11 日
編集済み: sheno39 2013 年 9 月 11 日
thanks for your help.. can u help me to code the following.. kindly reply.. function computedensity() for x in all pixels p[x] = 0; for n in all pixels less than 3 p[x]+=exp(-(f[x]-f[n])^2

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by