How to merge a contour plot with the image it is derived from
8 views (last 30 days)
Show older comments
Hello, I have this challenge of overlaying a contour plot with that of the image from which it was derived, as both images now have different scale axes. The program I used is attached along with the relevant mat file, jpg file from which the mat file was obtained and the resultant merged image I obtained. Please help. Thank you.
Z = load('Ir_6707.mat');
flds = fieldnames(Z);% Fieldnames of data.
field = flds{1};% First field in data structure.
A = Z.(field);
B = -272.+A;% converts from kelvin to celsius
H = fspecial('average');% Creates predefined average 2_D filter
image = imfilter(B,H);% Applies filter to image
contour(flipud(image));
[C,h] = contour(interp2(flipud(image),'spline'));
clabel(C,h);
hold on
imagesc(flipud(B));
0 Comments
Answers (1)
Thorsten
on 20 Oct 2015
Edited: Thorsten
on 20 Oct 2015
I failed to run your code, because
>> contour(flipud(image));
Error using flipud (line 19)
X must be a 2-D matrix.
I use Matlab R2012a.
Note that you treat A as if is where a matrix of temperature values in Kelvin; but is seems to be an RGB image. Also the correct formula is celsius = kelvin - 273.15.
To show an overlay of the image and the contour:
Z = load('Ir_6707.mat');
flds = fieldnames(Z);% Fieldnames of data.
field = flds{1};% First field in data structure.
A = Z.(field);
G = rgb2gray(A);
H = fspecial('average');%
image = imfilter(G,H);
imshow(A)
contour(image)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!