Borrar filtros
Borrar filtros

i need code urgently for my project, please help me

3 visualizaciones (últimos 30 días)
viswanath reddy
viswanath reddy el 11 de En. de 2019
Comentada: viswanath reddy el 26 de En. de 2019
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?

Respuesta aceptada

Image Analyst
Image Analyst el 11 de En. de 2019
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

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by