How to merge a contour plot with the image it is derived from
Afficher commentaires plus anciens
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));
Réponses (1)
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)
2 commentaires
Ogheneochuko
le 20 Oct 2015
That's strange. After the first four lines, I get
>> whos A
Name Size Bytes Class Attributes
A 240x320x3 230400 uint8
which is definitely a valid argument for rgb2gray. Are you using a different A or mat-file?
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!