how to assign zero value to all pixels in an image ?
조회 수: 10 (최근 30일)
이전 댓글 표시
채택된 답변
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
추가 답변 (2개)
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
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)?
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!