Can you help me to correct this error?

1 次查看(过去 30 天)
Carole
Carole 2012-10-30
Hi,I had this error
??? Error using ==> times
Number of array dimensions must match for binary array op.
Error in ==> code at 55
mult=image.*bw;
I used this line to correct it
size(image)=size(bw)
but i have now this error
??? Subscript indices must either be real positive integers or logicals.
Error in ==> code at 54
size(image)=size(bw)
can you help me to correct it, thanks

回答(1 个)

Image Analyst
Image Analyst 2012-10-30
That line won't correct it. First of all, image() is a built - in function name and you can't use it like "image.*bw" because functions need to be passed arguments.
Next, even if it were a variable name (meaning you blew away the built-in function called image()), then you should try to figure out why you're multiplying two images together that aren't the same size. What would that mean to you? How could you do that?
Next, if you did want to resize one of them, say bw, you'd do
[rows, columns, numberOfColorChannels] = size(yourImage);
resizedBW = imresize(bw, [rows columns]);
mult = yourImage .* resizedBW;
  2 个评论
Carole
Carole 2012-10-30
result = image_luv .* bw;
ok I changed the name of the image but I can't use imresize because image_luv et bw have the same number of rows and columns. image_luv is an Luv image and bw is a binary image of the component L
size(image_luv) =
525 250 3
size(bw) =
525 250
Image Analyst
Image Analyst 2012-10-30
Your image is color - that's why. You can do it this way:
% Mask the image.
maskedluvImage = bsxfun(@times, image_luv, cast(bw, class(image_luv)));

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by