I have 2 contours on the same plot and I want to differentiate them with colours so I can see the difference.

Hi,
Please see the attaced Frame 16&17. In this image 2 contours from 2 consecutive frames are plot to analyse the change.
My question is how can I change the boundary colour of contour so I can easily differentiate between 2 or if I plot more contour on it.
I used the command below to plot the contours and would like the add on for coulour into it.
% contour of the image
figure()
imcontour(dif,2);
hold on
imcontour(dif1,2);
hold off

2 Kommentare

Can you create an example? What do you mean by 'difference'?
Please see the attached!
I want to represent contours with different colour and then use the threshold value to reduce the disturbance
imcontour(dif,2,'LineColor','r');
But I am getting error!
Error using imcontour
Expected input number 3, I, to be one of these types:
uint8, int16, uint16, double, logical, single
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 RCGCoPixelMov (line 28)
imcontour(dif,2,'LineColor','r');

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

I = imread('rice.png');
figure,subplot(121),
imcontour(I);ax = gca;
colormap(ax,'cool')
subplot(122);
imcontour(I);ax = gca;
colormap(ax,'hot')

EDIT:

Change LineColor
I = imread('rice.png');
figure,
imcontour(I,'LineColor','r')
hold on
I = imread('cameraman.tif');
imcontour(I)

3 Kommentare

Hi Mehmed,
You sort of solve the problem but I am getting the error while using the same method.
Code used:
figure()
imcontour(dif,2,'LineColor','r');
hold on
imcontour(dif1,2);
hold off
Error:
Error using imcontour
Expected input number 3, I, to be one of these types:
uint8, int16, uint16, double, logical, single
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 RCGCoPixelMov (line 28)
imcontour(dif,2,'LineColor','r');
But if I removed the 2 (threshold value) it works but then I am getting alot of disturbance as well. Please see the attached files.
dif = imread('rice.png');
figure()
imcontour(dif,2);
hold on
dif1 = imread('cameraman.tif');
imcontour(dif1,2);
hold off
cts = findobj(gca,'Type','contour');
cts(1).LineColor = 'flat';
cts(2).LineColor = 'r';
@Mehmed Saad, Legend!
thanks for the help. I might ask you guys few more questions as I progresses!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by