Non-pixelized image using imagesc (or alternatives)
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Richard Wood
am 29 Mär. 2023
Kommentiert: Bjorn Gustavsson
am 29 Mär. 2023
Hello everyone
I have generated an image using imagesc, which looks like this
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1339444/image.png)
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 Kommentare
Akzeptierte Antwort
Antoni Garcia-Herreros
am 29 Mär. 2023
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 Kommentare
Antoni Garcia-Herreros
am 29 Mär. 2023
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.
Weitere Antworten (2)
Bjorn Gustavsson
am 29 Mär. 2023
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 Kommentare
Bjorn Gustavsson
am 29 Mär. 2023
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
am 29 Mär. 2023
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 Kommentare
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!