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

조회 수: 2 (최근 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.
Sat m
Sat m 2013년 2월 16일
thank you...i am displaying 4 images separately. it is working now.. thank you

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

추가 답변 (0개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by