pixel by pixel squaring of image?
조회 수: 1 (최근 30일)
이전 댓글 표시
If I have an image of size M by N then how can I do the square of each pixel individually?
댓글 수: 0
답변 (1개)
Sabarinathan Vadivelu
2016년 8월 12일
outImage = zeros(size(inputImage));
for i = 1 : size(inputImage, 1)
for j = 1 : size(inputImage, 2)
outImage(i, j) = inputImage(i,j)^2;
end
end
댓글 수: 4
maaham banu
2019년 11월 22일
hi, why doesnt this algorithm work for a gray image? I am getting only 255
Image Analyst
2019년 11월 22일
Because if the value goes above 255, it clips to 255. You'll have to use uint16 or double. And don't use a for loop like this answer did. Use dot caret instead:
outImage = double(inputImage) .^ 2; % or uint16()
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!