can you tell me what does this means. .
repmat(okpxls, [1, 1, 3]);
and zeros(size(img), class(img));
pls reply asap. .

 采纳的回答

Enter
size(okpxls)
after the line:
okpxls = minr <= r & r <= maxr & ming <= g & g <= maxg & minb <= b & b <= maxb;
What I think you will see is that okpxls is a 2-D matrix the same size as r, g, and b.
Then the line:
okpxls = repmat(okpxls,[1 1 3])
says take that 2-D matrix okpxls and replicate that exact 2-D matrix into a MxNx3 matrix
Look at this very simple example
x = randn(2,2);
x1 = repmat(x,[1 1 3]);
Now if you enter
size(x1)
You see that x1 is 2x2x3 and furthermore that
x1(:,:,1) is equal to x, x1(:,:,2) is equal to x, and x1(:,:,3) is equal to x
Please read the documentation for repmat.

更多回答(1 个)

repmat(okpxls,[1 1 3]) replicates (copies) an input into 3-D.
x = randn(3,1);
y = repmat(x,[1 1 3]);
y has the same row and column size as x, but has dimension 3 along the third dimension.
Another example:
x = randn(2,2);
y = repmat(x,[1 1 3]);
size(y)
zeros(size(img), class(img));
creates a matrix of zeros the same size and class as image
x1 = uint8(randn(8,8));
x2 = zeros(size(x1),class(x1));

4 个评论

didn't get clearly though. . .
pls one more try. .
if x is 2x2, then y = repmat(x,[1 1 2]) takes that 2x2 matrix and copies that matrix into 2x2x3 matrix where every 3rd dimension is just a copy of the original 2x2 matrix
x = randn(2,2);
y = repmat(x,[1 1 3]);
y is now 2x2x3 and
y(:,:,1)
y(:,:,2)
y(:,:,3)
are all equal to x
as far as zeros()
if x has a certain class, say unsigned 8-bit integer
x = uint8(randn(2,2))
size(x)
class(x)
then
y = zeros(size(x),class(x))
creates an array, vector, etc the same size as x AND of the same class
okpxls = minr <= r & r <= maxr & ming <= g & g <= maxg & minb <= b & b <= maxb;
okpxls = repmat(okpxls, [1, 1, 3]);
newimg = zeros(size(img), class(img));
what i didnt get was [1 1 3]
what does this mean

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Data Distribution Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by