Can anyone help with this error? (I just want to see the contour of the bluish area at the bottom of the image)

1 visualización (últimos 30 días)
close all
clear all
clc
I = imread('frame75.jpg');
imshow(I)
imcontour(I,3)
Error:
Error in imcontour>ParseInputs (line 110)
validateattributes(a,{'uint8','int16','uint16','double','logical','single'}, ...
Error in imcontour (line 40)
[x,y,a,extra_args] = ParseInputs(varargin{:});
Error in contour (line 8)
imcontour(I,3)

Respuesta aceptada

darova
darova el 1 de Jul. de 2020
Detect blue region properly
I0 = imread('frame75.jpg');
I1 = double(I0);
% colors from blue region
R = [80 50 0];
G = [160 110 70];
B = [180 120 70];
B1 = logical(I1(:,:,1)*0);
% detect regions and merge
for i = 1:length(R)
B0 = abs(I1(:,:,1)-R(i)) < 20 & ...
abs(I1(:,:,2)-G(i)) < 50 & ...
abs(I1(:,:,3)-B(i)) < 50;
B1 = B1 | B0;
end
% B1 = uint8( cat(3,B1,B1,B1) );
imshowpair(I0,B1)
% imshow(B1.*I0)
  12 comentarios
muhammad choudhry
muhammad choudhry el 3 de Jul. de 2020
You the man! seriously..... It worked
I got the answer
ans = 431
just wondering when I counted manually answer was 486 and with binarizing 431... differrence in pixels are like 55. Do you know why there is that difference?
sum(~A1(:)) => means it is adding all the pixels in the image except white background

Iniciar sesión para comentar.

Más respuestas (1)

Ameer Hamza
Ameer Hamza el 27 de Jun. de 2020
You need to specify a single channel image to imcontour(). For example, just provide the blue channel
imcontour(I(:,:,3), 3)
or convert image to grayscale
imcontour(rgb2gray(I), 3)
  1 comentario
muhammad choudhry
muhammad choudhry el 29 de Jun. de 2020
Editada: darova el 1 de Jul. de 2020
Hi,
Hamza please see the attached. I have changed to grey scale function to capture the contour of the injected dye flow but I am also getting the contours of other background is there a way to only capture the dye contour.
here is a code I used!
close all
clear all
clc
%Read the Image
I = imread('frame75.jpg');
I1 = imread('frame80.jpg');
warning('off', 'Images:initSize:adjustingMag');
%Convert to greyscale (contour command works on greyscale images)
img=rgb2gray(I);
img1=rgb2gray(I1);
%Subtraction of the frames
figure()
dif=img-img1;
warning('off', 'Images:initSize:adjustingMag');
imshow(dif)
hold on
% contour of the image
figure()
imcontour(dif,1);

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by