필터 지우기
필터 지우기

i need code urgently for my project, please help me

조회 수: 3 (최근 30일)
viswanath reddy
viswanath reddy 2019년 1월 11일
댓글: viswanath reddy 2019년 1월 26일
i want code for comparison of pixels in an image by considering a 3*3 matrix. for each pixel, a 3*3 matrix around the pixel should be considered and the pixel must be compared with both the diagonals of the considered 3*3 matrix, whether the pixel is greater than all the diagonal elements or not?

채택된 답변

Image Analyst
Image Analyst 2019년 1월 11일
If you're not turning it in for homework, you can use my code below which uses highly optimized 2-D convolution:
grayImage = imread('cameraman.tif');
subplot(1, 2, 1);
imshow(grayImage, []);
% Do one corner
kernel = [-1,0,0;0,1,0; 0,0,0];
filter1 = conv2(grayImage, kernel, 'same');
% Do another corner
kernel = [0,0,-1;0,1,0; 0,0,0];
filter2 = conv2(grayImage, kernel, 'same');
% Do another corner
kernel = [0,0,0;0,1,0; -1,0,0];
filter3 = conv2(grayImage, kernel, 'same');
% Do another corner
kernel = [0,0,0;0,1,0; 0,0,-1];
filter4 = conv2(grayImage, kernel, 'same');
% Output must have middle pixel greater than all 4 corners.
outputImage = (filter1 > 0) & (filter2 > 0) & (filter3 > 0) & (filter4 > 0);
subplot(1, 2, 2);
imshow(outputImage, []);
0000 Screenshot.png

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by