Non-pixelized image using imagesc (or alternatives)

조회 수: 33 (최근 30일)
Roderick
Roderick 2023년 3월 29일
댓글: Bjorn Gustavsson 2023년 3월 29일
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?
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.

채택된 답변

Antoni Garcia-Herreros
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
Roderick
Roderick 2023년 3월 29일
Dear Antoni
Thank you for your response. What I want is my data to look as fine as the similar one that can be found in https://assets.researchsquare.com/files/rs-1646710/v1_covered.pdf?c=1660806730 (Fig. 2a). I was said that in my image above is impossible to see anything, and that it is all pixels. I am attaching the data in the main post.
In that sense, I do not know if imresize fulfills what I am trying to obtain, that it is, a more smooth transition between the colored regions (non-visible-pixel-like regions at all).
Antoni Garcia-Herreros
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
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
Roderick
Roderick 2023년 3월 29일
Dear Bjorn
The video was an example for the first frame, that it is more or less similar to my figure. In https://assets.researchsquare.com/files/rs-1646710/v1_covered.pdf?c=1660806730 (Fig. 2a) you can find a static one, to which quality I am trying to point out from my data (attached in the main post). The objective is that in my image I would need the color regions to be pixel-like but more smooth than they actually are, as in the example of the aforementioned paper.
Bjorn Gustavsson
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
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.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by