简体   繁体   中英

Matlab: displaying 2D projections with specific color encoding as rgb images in 3D plot

As I could not find a solution by myself and related topics , I would like to to ask if someone can give me some hints how to resolve the following issue:

In a 3D plot it is possible to display 2D projections as (filled) contour plots by assigning the result of the function contourf to a graphics handle, as in the following matlab code fragment:

[~,h2]=contourf(w1,w3,sz,level_list2,'LineWidth',1);

h2=findobj(h2,'type','patch');

for j=1:length(h2),

     zd=w5(1).*ones(size(get(h2(j),'XData')));

     set(h2(j),'ZData',zd);

end

set(h2,'FaceLighting','none');

The arguments w1 and w3 of the function contourf define the x- and y-axis of the 3D plot, while sz contains the projection of the three-dimensional data set onto the (x,y)-plane.

However, as I want to use a specific color encoding for the 2D projection, a (filled) contour plot doesn't seem to be the appropriate solution. Rather, the 2D projection is given as a RGB image after applying the procedure for the desired color encoding.

Therefore I tried to use the function mapshow , which seems to be more appropriate in this case. Then the corresponding code fragment reads

[~,h2]=mapshow(w1,w3,szIndexedImage,hsv);

h2=findobj(h2,'type','patch');

for j=1:length(h2),

    zd=w5(1).*ones(size(get(h2(j),'XData')));

    set(h2(j),'ZData',zd);

end

set(h2,'FaceLighting','none');

where the indexed image szIndexedImage is obtained from the rgb image szRGBimage via

szIndexedImage=rgb2ind(szRGBimage,hsv);

and hsv is the HSV color map.

Running the program leads to the error message

Error in `mapshow` (line 214)
error(nargchk(1,Inf,nargin,'struct'))

Output argument "varargout" (and maybe others) not assigned during call to
"/usr/local/MATLAB/R2012a/toolbox/map/map/mapshow.m>mapshow".

Thanks a lot for any ideas which could help me to resolve this issue.

Best regards,

Joachim

You are calling mapshow with output argument "[~,h2]", but mapshow only returns one output (the handle). So while with contourf this means "don't return contour matrix, do return handle", with mapshow it doesn't make sense.

Just replacing [~,h2] with h2 should remove the error you're currently getting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM