What is Pixels and what is gray level value ? and how to calculate all distances between them

7 次查看(过去 30 天)
7 by 7 matrix with entries 1 to 49.Each value is gray level of a pixel.
find the following distance between pixels with gray level 25 and 36.
  1. uclidean Distance
  2. City Block Distance
  3. Chessboard Distance

采纳的回答

Image Analyst
Image Analyst 2020-2-9
A pixel is an element of a matrix that represents something (like reflectance) of a certain scene. The gray level is the numerical valuke of the pixel. To find the distances between all possible pairs of pixels having gray levels 25 and 36 you need to first get the map of where those pixels are, then pass them into pdist2(). Since it sounds tremendously like homework, I'll give you hints so you don't get into trouble turning in my code as your own:
map25 = grayImage == 25;
map36 = ..............
[rows25, columns25] = find(map25);
xy25 = [columns25(:), rows25(:)];
distances = pdist2(xy25, ......................
That's pretty much it. Just fill out the code to get stuff for the 36 case and pass in the right distance method into pdist2, which is in the Statistics and Machine Learning Toolbox.
  4 个评论
Muhammad Tayyab
Muhammad Tayyab 2020-2-10
presentation means .. i am student and i have presentation on this topic in the class given by my teacher .. and i have to find the (1) chessboard distance (2) Euclidean distance (3) City block distance .... i have to create Code (Functions) for these formulas
Image Analyst
Image Analyst 2020-2-10
My code gives the Euclidean distance, however pdist2() has other distance metrics you can use, like city block, etc. What is chessboard distance? How is it different than city block distance, which is the sum of the delta x plus deltay?

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by