フィルターのクリア

To find the centeral pixel of coloured image ... ?

3 ビュー (過去 30 日間)
jagkaran
jagkaran 2011 年 10 月 30 日
i want to find the centeral pixel of a nxn window of a colored image of size 512x512 ...
say, i want to make a matrix of 3x3 and so 5x5 and so on to find out the centeral pixel within that window ...
is there any method or command to find out ???

回答 (3 件)

Image Analyst
Image Analyst 2011 年 10 月 31 日
So ambigous. What is "matrix"? Is that "window" or is that "image"? If you have an image, and you have a location (row, column) where the n-by-n window is centered (with n being odd such as 3, 5, or 7) then the center pixel is located at (row, column) and it does not depend on the window size. For example a window located at row=100, column=200 and width 3 will cover rows going from 99 to 101 and 199 to 201, but the center is still at 100, 200 regardless of what the window size is. The color values can be extracted like this:
redValue = rgbImage(row, column, 1);
greenValue = rgbImage(row, column, 2);
blueValue = rgbImage(row, column, 3);
  1 件のコメント
jagkaran
jagkaran 2011 年 11 月 8 日
the colour components u have told ... that i have already understood ... i want to know the method to find the centeral pixel ...

サインインしてコメントする。


Walter Roberson
Walter Roberson 2011 年 10 月 31 日
blockproc() or (for older systems) blkproc()
Also, I am by no means certain, but I think you might be able to do it for odd-sized n x n windows as:
mask = zeros(n); mask(ceil(numel(mask)/2)) = 1;
conv2(YourImage, mask)
I think that you will find that in practice the output looks almost exactly like YourImage...
  2 件のコメント
jagkaran
jagkaran 2011 年 11 月 8 日
what does this numel denotes ...?
Image Analyst
Image Analyst 2011 年 11 月 8 日
Have you looked in the help? Apparently not because it's right in there. It's one of the main functions of MATLAB. You should really learn to use the help before asking people, especially for functions that are right in there.

サインインしてコメントする。


Walter Roberson
Walter Roberson 2011 年 11 月 8 日
If you have a 3 x 3 mask, the central pixel is at index (2,2), which is ( (3+1)/2, (3+1)/2 ). Index (2,2) inside a 3 x 3 matrix is at MATLAB absolute index position 5, which is (3*3 + 1)/2
If you have a 5 x 5 mask, the central pixel is at index (3,3), which is ( (5+1)/2, (5+1)/2 ). Index (3,3) inside a 5 x 5 matrix is at MATLAB absolute index position 13, which is (5*5 + 1)/2
In general, for an n x n mask, the central pixel is at index ( (n+1)/2, (n+1)/2 ), which is at MATLAB absolute index (n * n + 1)/2
So now you know how to find the central pixel of an square matrix with odd-numbered dimensions.
Not very exciting at all. And if you use a sliding window technique with overlaps, extracting the central pixel each time will be exactly the same as the original image (except perhaps with the border cropped).

カテゴリ

Help Center および File ExchangeData Clustering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by