MATLAB: concatenition of 2 images in a frame: resulting images of 2 parts of code seem to be overwriting each other

3 次查看(过去 30 天)
%......section (e)
C1 = imread(InputImage);
NumberOfLevels = 2;
n = 32;
C1q1=uint8(rgb2ind(C1,n)*(NumberOfLevels-1));
imshow(C1q1,[]);
NumberOfLevels=4;
n = 32;
C1q2=uint8(rgb2ind(C1,n)*(NumberOfLevels-1));
imshow(C1q2,[]);
no8=figure;
C1img = [C1q1;C1q2];
image(C1img);
%........end of section (e)
%....section (f)
C1 = imread(InputImage);
C1 = double(C1);
NumberOfGrayLevels=32;
I= 0.299*C1(:,:,1)+0.587*C1(:,:,2)+0.114*C1(:,:,3);
C = 1;
I=(C*log(I+1))';
new=uint8(mat2gray(I)*(NumberOfGrayLevels-1));
[m,n]= size(new);
rgb = zeros(m,n,3);
rgb(:,:,1) = new;
rgb(:,:,2) = rgb(:,:,1);
rgb(:,:,3) = rgb(:,:,2);
new = rgb/256;
imshow(new,[]);
no9=figure;
image(new);
%...........end of section (f)
when i put a break command before %.....section(f) (i.e. when i execute only section (e)) then i can see concatenated image for C1q1 and C1q2 in a single frame as it should be. but when i remove the break command (i.e.) when i execute both section(e) and section (f) then i can see that result of section (f) is overwriting result in section (e). instead of seeing C1q1 and C1q2 in a frame, i see figure (new) in both frames. i cannot see C1q1 and C1q2 anymore. can you tell me why is this happening and how to overcome this?

采纳的回答

Walter Roberson
Walter Roberson 2013-2-16
Try adding a drawnow() after the image() command.
Your imshow(new,[]) is erasing your existing image() in the same axes. Where do you want the imshow() to be displayed, and is there a particular reason you have both imshow(new,[]) and image(new) ?
  6 个评论
Walter Roberson
Walter Roberson 2013-2-16
Each cla will erase what has gone before. If you want to show all four images at the same time, you will need to use different figures for each, or use subplot(), or use the XData and YData parameters to imshow() in order to position the images all on the same axes but not overlapping.

请先登录,再进行评论。

更多回答(0 个)

产品

Community Treasure Hunt

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

Start Hunting!

Translated by