Non-pixelized image using imagesc (or alternatives)
조회 수: 33 (최근 30일)
이전 댓글 표시
Hello everyone
I have generated an image using imagesc, which looks like this
The problem is that you can see the pixels, and it has no quality enough to show in a scientific meeting. My matrix has 115x85 elements.
Any idea on how to display this image in a much more smooth and clear way?
Hopefully I would obtain a image resolution like this one: https://static-content.springer.com/esm/art%3A10.1038%2Fs41524-022-00864-x/MediaObjects/41524_2022_864_MOESM3_ESM.mp4
I am attaching the relevant data for the plot. With this, I write to plot it:
u1=figure();
imagesc(space_x,space_y,matrix);
axis xy;
colormap(cmap);
box on;
clr1=colorbar('YTickLabel',{'-1','-0.5','0','0.5','1'},'YTick',[-1:0.5:1]);
xlabel('$x$-{\it th} spatial direction, $x \, \, \left( \mathrm{nm} \right)$','FontSize',14,'interpreter','latex');
ylabel('$y$-{\it th} spatial direction, $y \, \, \left( \mathrm{nm} \right)$','FontSize',14,'interpreter','latex');
ylabel(clr1,'$x$-{\it th} magnetization component, $m_x$','Interpreter','Latex','FontSize',14);
caxis([-1 1]);
xlim([0 40]);
ylim([0 40]);
t1=title(['$t=0$ ns, $T=200$ K, $\mathbf{H}=0$'],'FontSize',14,'interpreter','latex');
set(t1,'interpreter','latex','FontSize',14);
set(gca,'TickLabelInterpreter','latex','FontSize',14);
set(u1,'Units','Inches');
posu1=get(u1,'Position');
set(u1,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[posu1(3),posu1(4)]);
cmap is user-defined colormap, it can be changed to other one.
댓글 수: 0
채택된 답변
Antoni Garcia-Herreros
2023년 3월 29일
Hello,
I guess that what you want to do is interpolate the data into a larger image. You could take a look at imresize and adjust the interpolation method that works best for your case.
Image=rand(115,85); % Generate a 2D-array of datapoints with dimensions 115x85, just as your image
LargerImage=imresize(Image,10*size(Image),'bilinear'); % Resize the image by a factor of 10.
imagesc(LargerImage)
댓글 수: 2
Antoni Garcia-Herreros
2023년 3월 29일
Sorry, I don't understand exactly what's your problem.
"a more smooth transition between the colored regions."
That is exactly what the function resize is doing.
추가 답변 (2개)
Bjorn Gustavsson
2023년 3월 29일
That was not an immage you linked to but rather a movie (at a push a sequence of images). The first frame seemed reasonably similar to your random one. Then there might be any of a number of operations done to the consecutive frames. One thing that might occur is simple linear diffusion (corresponding to convolution with a 2-D Gaussian). For example something like this:
I = randn(128,64); % mock-up of initial frame
fK = [0.125,.25,0.125;0.25 1 0.25;0.125, 0.25 0.125]; % filter-kernel to convolve image with
fK = fK/sum(fK(:)); % normalize it to add to 1
for i1 = 1:200
imagesc(I)
drawnow
I = imfilter(I,fK,'symmetric'); % you could also use plain conv2: I = conv2(I,fK,'same');
end
This is not exactly what is done in the video you linked to but it should be enough to get you going, and from the information given it is "slightly challenging" to do your research job for you...
HTH
댓글 수: 2
Bjorn Gustavsson
2023년 3월 29일
The top left frame in fig 2 clearly has larger number of pixels than 128 x 64 - perhaps 1024 x 512 or even 2048 x 1024 - if you simply increase the size of I in my suggestion to that size and then run the exact same diffusion on that image you will pass through a region where I looks rather similar to fig 2a - which you could use as your "initial image".
Image Analyst
2023년 3월 29일
However you created that image, you simply need to create it with more pixels. You can use imresize and then blur it, but it won't be the same and will look blurred. If you want sharp edges, you're just going to have to have more resolution.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!