I have a webcam image "ref2" and I want to overlap the heatmap "pp" over it. In the program I have a video preview coming from a webcam and I have to put a heatmap over it. Can anyone please help me with this?

답변 (1개)

Matlab Pro
Matlab Pro 2024년 5월 27일

1 개 추천

댓글 수: 4

Ron
Ron 2024년 5월 28일
Thankyou so much for reaching out to answer. The solution did solve my problem to an extent. Now the issue is that the heatmap has limits [-90 90] in both x and y axes but the image is of the resoultion 1024*768n so the overlap of the two is missing. I guess some kind of scaling is required but I am not sure how to do that.
DGM
DGM 2024년 5월 29일
편집: DGM 2024년 5월 29일
In the call to image()/imagesc()/imshow(), you can specify the xdata and ydata as 2-element tuples representing the intended interval over which the image should be displayed. See the help synopsis for the corresponding function to see how that's done.
I'm assuming that you're doing in-figure compositing. If you're doing something else, you'll have to say. IIRC, the linked thread includes several different conceptual approaches to a similar problem, so it's hard to infer what you might have adopted from it.
Ron
Ron 2024년 5월 29일
편집: Ron 2024년 5월 29일
Sorry but I cannot understand what you are trying to infer here. To get this figure this is the code that I am using.
n=1;
vid = videoinput('winvideo');
app.vid_handle=vid;
vidInfo = imaqhwinfo(vid);
vidRes = vid.VideoResolution;
imWidth = round(vidRes(1)/n);
imHeight = round(vidRes(2)/n);
numBands = vid.NumberOfBands;
preview(vid, hImage); hold on
pp3=pcolor(app.UIAxes4_2,xx,yy,10*log10(P3));hold on
pp3.EdgeColor="none";
set(app.UIAxes4_2,'Xdir','reverse')
pp3.EdgeColor='none';
pp3.FaceColor="interp";
pp3.FaceAlpha=.3;
colormap(app.UIAxes4_2,"jet")
colorbar(app.UIAxes4_2,"eastoutside")
axis equal
colorbar(app.UIAxes4_2);
here P3 is the NxN matrix for the heatmap. I do not want to change the resolution of the video image. I want my heatmap to overlap with the axes of image perfectly. Maybe my code is not using the best possible way of doing this so can you please suggest a better way of doing this?? Thankyou
DGM
DGM 2024년 5월 30일
I'm not sure what your axes setup is. It looks like you're using two overlaid axes, though I'm not sure if those are axes objects or uiaxes objects. I'm guessing uiaxes, since it's an appdesigner thing?
I'm not sure how the preview() tool occupies the parent axes, and whether it's truly necessary to use overlaid axes. I don't have imaq toolbox.
Either way, assuming that it's necessary to overlay axes, it would be necessary to look at the xlim, ylim of the two axes and figure out how to get them to correspond. If your two axes have the same position, and the xlim,ylim of the pcolor() axes are such that they contain the extents of the given xx,yy, then the pcolor() plot should lie atop the preview() image.
I didn't expect you to be using pcolor(). If that's working for you, that's fine. The way pcolor() is used, you're already giving it xdata and ydata in the function call, so it's all explicit. I thought you were doing this in one axes with overlaid objects.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품

릴리스

R2023a

질문:

Ron
2024년 5월 25일

댓글:

DGM
2024년 5월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by