Creating a "mask" over an image
이전 댓글 표시
I am given a project using matlab. With an image I am supposed to separate the RGB of the image into 3 2 dimensional matrices. This is the current code that I have used
r = f1(:,:,1); %assigns first color layer to variable r
g = f1(:,:,2); %assigns second color layer to variable g
b = f1(:,:,3); %assigns third color layer to variable b
The next step of the project is to use the matrix set for green values and by using only implicit commands create a new matrix that contains indices for green that are larger than the intensity threshold that is assigned by the user when asked. The matrix should be "number of pixels" x "number of pixels". How would you do this? This is the current method I am using, is it correct?
m1 = g>=n;
figure(3)
image(m1)
Furthermore, I am suppose to create a new matrix with "number of pixels" x "number of pixels" x 3 where the matrix created with the intensity threshold is duplicated along the 3 dimensions and generates a "mask" that tells whether or not the RGB content at any pixel met the given value. How would you do this? I have no code thus far for it.
댓글 수: 2
Bhumika Patel
2017년 5월 12일
how to explain how the mask is created??? please answer me the explantion of creating the mask.
Walter Roberson
2017년 5월 12일
Bhumika Patel:
There is no one way of creating masks.
One of the typical ways of creating a mask is to compute the value of some property for each location in the image, and then use comparisons to determine whether the value of that property is in some range.
For example, you might start with an RGB image, and convert it to HSV (Hue, Saturation, Value), and then check to see whether the Hue is within some particular range that corresponds to (for example) orange.
Or you might decide to find the maximum value in a data array, and compute the Euclidean distance from each pixel in the array to the location of the maximum value, and then check to see whether the euclidean distance is within some particular range -- this would correspond to taking a circle around the maximum location.
There are a lot of other ways to compute masks. For example, you can have a mask computed by watershed analysis, or by texture analysis, or by correlation with a known shape, or by circle finding...
채택된 답변
추가 답변 (1개)
Matt J
2013년 10월 8일
cat(3,m1,m1,m1)
or
repmat(m1,1,1,3);
카테고리
도움말 센터 및 File Exchange에서 Display 2-D Images에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!