Which one of the following is an efficient code for this MATLAB?

删除回忆录丶 提交于 2019-12-13 11:24:25

问题


Arrange the 2 given images into one image with image1 (pedestrian) on the left and image2 (no-parking) on the right in one single image. Display the combined single image.

Code 1 :-

z = imread('NO_PARKING.jpg');

x = imread('PEDESTRIAN.jpg');

r = imresize(z,[500,500]);

c = cat(2,x,r);

imshow(c)

Code 2:-

[X1,map1]=imread('PEDESTRIAN.jpg');

[X2,map2]=imread('NO_PARKING.jpg');

subplot(1,2,1), imshow(X1,map1)

subplot(1,2,2), imshow(X2,map2)

Which of the above codes is correct?


回答1:


The two codes don't do the same thing, so it's not a matter of efficiency. One combines the two images into one, then displays that one image, one just displays the two images in one figure.

If you really want to understand the difference in practice, you may consider:

  • Using two images which are different sizes

  • Using two images which are the same size but do not have white backgrounds

  • A further operation, such as rendering the combined image greyscale or applying a smoothing filter



来源:https://stackoverflow.com/questions/53570987/which-one-of-the-following-is-an-efficient-code-for-this-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!