필터 지우기
필터 지우기

I need code urgently for my project to find average of pixels by considering 7 by 7 matrix

조회 수: 2 (최근 30일)
I want code for finding the mean by considering 7 by 7 matrix. For each pixel in the image i want to calculate 5 mean values. First mean should be calculated by placing the original pixel at the center of 7 by 7 matrix and the second,third,fourth and fifth mean should be calculated by placing the same pixel at top left,top right,bottom left,bottom right of the 7 by 7 matrix.
  댓글 수: 3
Jan
Jan 2019년 1월 28일
What have you tried so far? What is your question?

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2019년 1월 28일
Use filter2()
The mask you pass to filter2 is applied with the pixel at the top left if I remember correctly. However can ask for the full results rather than 'valid' and you can extract subsets of the filtered results . MM(1:end-6,1:end-6), MM(7:end,1:end-6) and so on where MM is the output of filter2 .
  댓글 수: 3
viswanath reddy
viswanath reddy 2019년 1월 28일
I need to calculate 5 mean values of every pixel in an image. The first mean value should be calculated by assuming the pixel at the center of 7*7 window and the 2nd,3rd,4th and 5th mean values should be calculated by assuming that the same pixel is located at top left,top right,bottom left and bottom right corners of the 7*7 window.
Walter Roberson
Walter Roberson 2019년 1월 28일
you already said that in the same words. If I did not understand your question then you need to explain differently such as with an example .

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2019년 1월 28일
Try this:
grayImage = imread('moon.tif'); % Whatever ...
% Shift pixel at upper left to middle.
kernel = zeros(7);
kernel(1,1) = 1;
upperLeft = imfilter(grayImage, kernel);
% imshow(upperLeft);
% Shift pixel at upper right to middle.
kernel = zeros(7);
kernel(1,3) = 1;
upperRight = imfilter(grayImage, kernel);
% imshow(upperRight);
% Shift pixel at lower left to middle.
kernel = zeros(7);
kernel(3,1) = 1;
lowerLeft = imfilter(grayImage, kernel);
% imshow(lowerLeft);
% Shift pixel at lower right to middle.
kernel = zeros(7);
kernel(3,3) = 1;
lowerRight = imfilter(grayImage, kernel);
% imshow(lowerRight);
But it's not really correct to call the pixel at the upper left of a 7x7 window a "mean" since it's just a single pixe,, not the average of multiple values.

Community Treasure Hunt

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

Start Hunting!

Translated by