I can't receive output using imshow() after imbinarize() function in my Image Processing job.

9 次查看(过去 30 天)
Hi everybody!
I read 2 images to the workspace and prior to applying XOR operator, I'm trying to Binarize the input images using imbinarize() function, however, I receive an error using imshow() to display. I appreciate any assistance in resolving the issue.
Here is the code:
I1 = imread('D:/i_p_pics/Bird_1.jpg');
I2 = imread('D:/i_p_pics/Bird_2.jpg');
BW1 = imbinarize(I1);
BW2 = imbinarize(I2);
output = xor(BW1,BW2);
subplot(321); imshow(I1); title('First Image');
subplot(322); imshow(I2); title('Second Image');
subplot(323); imshow(BW1); title('First Binary Image');
subplot(324); imshow(BW2); title('Second Binary Image');
subplot(325); imshow(output); title('XORED Image');
Here is the error:
common_args.CData = validateCData(common_args.CData,image_type);
Error in images.internal.imageDisplayParseInputs (line 78)
common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 245)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Error in oh (line 19)
subplot(323); imshow(BW1); title('First Binary Image');

回答(2 个)

Image Analyst
Image Analyst 2022-4-16
Try this:
I1 = imread('Bird_1.jpg');
I2 = imread('Bird_2.jpg');
% The BW are 3-D images because I1 and I2 were RGB.
% Process only the blue channel, which has the most contrast.
BW1 = imbinarize(I1(:, :, 3));
BW2 = imbinarize(I2(:, :, 3));
output = xor(BW1,BW2);
subplot(321); imshow(I1); title('First Image');
subplot(322); imshow(I2); title('Second Image');
subplot(323); imshow(BW1); title('First Binary Image');
subplot(324); imshow(BW2); title('Second Binary Image');
subplot(325); imshow(output); title('XORED Image');
  2 个评论
Image Analyst
Image Analyst 2022-4-16
Arash, the original problem was that imbinarize will binarize each plane it it's an RGB image, which is what you werer giving it. So it's a 3-D logical image, which imshow doesn't handle.
If it answered your question, the usual thing to do is to click the "Accept this Answer" link 🙂, unless you want to wait for better ones.

请先登录,再进行评论。


dhivya
dhivya 2023-3-14
hello,everyone i want 2 shares from this code and at the last line i use xor oprtion to reteive the original binary image.But i cannot retrieve it.Anyone pls suggest me quickly.(i take one binary image and generate two shares,after perfom xor opeartion restore original binary image)
S = imread('text input.png');
meven = [0 0 0; 0 1 1; 1 0 1; 1 1 0];
modd = [0 0 1; 0 1 0; 1 0 0; 1 1 1];
no = 1;
y = zeros(size(S));
R = zeros(size(S));
l = zeros(size(S));
for i = 1:size(S,1)
for j = 1:size(S,2)
if (S(i, j) == 0)
r = rand([no,2^no-1]);
disp(r)
ro = round(r);
ro = ro+1;
R(i,j) = meven(ro,1);
l(i,j) = meven(ro,2);
else
r = rand([no,2^no-1]);
disp(r)
ro = round(r);
ro = ro+1;
R(i,j) = modd(ro,1);
l(i,j) = modd(ro,2);
end
y(i,j) = S(i,j);
c=xor(R,l);
end
end
  1 个评论
Image Analyst
Image Analyst 2023-3-14
@dhivya how is this an answer to @Arash's question about XORing two bird images? Did you mean to post this as your own new question instead of an Answer to this question?

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by