Plotting pcolor plot on an image at a particular area.
이전 댓글 표시
Hi,
I have done some analysis on a particular region of an image which I now want to plot on the over the image. Following image is an example of what I am trying to get as output ( In my case it is a complete pacman shape but some region would be removed because of NaNs):
Now, I can plot the pcolor of the colored region separatly but am unable to get it with image. Colorbar changes to the gray values. Attached is the relevant binary matrix (region) which shows the region where the profile should be as well as image (img) which is suppose to be in the background and (out) is the values in the disc region.
댓글 수: 2
Mahesh Taparia
2019년 10월 4일
Hi,
It is not clear what you want to do with the 3 images you have attached. Can you explain clearly?
waqas
2019년 10월 4일
채택된 답변
추가 답변 (1개)
darova
2019년 10월 4일
You can just merge images
clc,clear
load matlab.mat
[m,n] = size(img);
[X,Y] = ndgrid(1:m,1:n);
Z = (X.*Y).*region; % try (X+Y)
Z = Z/max(Z(:)); % just scale 0 .. 1
% make RGB image: RED - 1, GREEN - changes, BLUE - 0
% result: red to orange
I1 = cat(3,Z*0+1,Z,Z*0);
mask = repmat(region,[1 1 3]);
I2 = double( repmat(img,[1 1 3]) );
I2 = I2/max(I2(:)); % scale 0 .. 1
I = I1 .* mask + I2 .* ~mask; % merge images
imshow(I);
cm = flipud(autumn);
colormap(cm)
h = colorbar;
댓글 수: 20
waqas
2019년 10월 8일
darova
2019년 10월 8일
How do you do this with patch? Can you show?
waqas
2019년 10월 8일
darova
2019년 10월 8일
DId you try to change colormap or manipulate with caxis? Maybe it's just a question of color?
waqas
2019년 10월 8일
darova
2019년 10월 8일
Can i see that script?
waqas
2019년 10월 8일
darova
2019년 10월 8일
But how do you paint that part in orange?
waqas
2019년 10월 8일
darova
2019년 10월 8일
Maybe create 2 different colormap
clc,clear
cla
load matlab.mat
h1 = imshow(img);
axis ij tight equal
% scale 'out': 255 .. 510
C2 = out - min(out(:));
C2 = C2/max(C2(:))*255;
C2 = round(C2)+255;
hold on
h2 = pcolor(C2);
hold off
set(h2,'EdgeColor','none')
set(h2,'FaceColor','flat')
% first 255 rows (1..255) is for 'img'
% second 255 rows (256..510) is for 'out'
colormap([gray(255); hot(255)]) % concantenate two different colormap
caxis([1 510])
% caxis([min(img(:)) max(C2(:))]) % doesn't work. Why?
This example from HERE
waqas
2019년 10월 8일
darova
2019년 10월 8일
Here is what the script produces. Isn't it great?

waqas
2019년 10월 8일
waqas
2019년 10월 8일
darova
2019년 10월 8일
try this
caxis(ax2,[min(out(:)) max(out(:))])
waqas
2019년 10월 8일
waqas
2019년 10월 8일
darova
2019년 10월 8일
You can hide it like you did before
ax2.Visible = 'off';
Or what do you mean? How do you want those figure look like?
waqas
2019년 10월 8일
darova
2019년 10월 8일
You can hide ticks
set(ax2,'xtick',[])
set(ax2,'xticklabel',[])
카테고리
도움말 센터 및 File Exchange에서 Color and Styling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


