image quality different in matlab

3 次查看(过去 30 天)
I have the following code. It generates a figure and then converts it into a pixel array "X". In another program I read that pixel array into a Java image and display it at the same resolution. The image qualities are very different. Why is this? How can I fix it? The first picture below is the figure in MATLAB, the second is the figure in Java.
fig=figure;
plot(L,mah)
hold
scatter(L(outliers==1),mah(outliers==1),'o')
legend(["Measurements","Outliers"])
xlabel("Measurement Sequence")
ylabel("Mahalanobis Distance")
title("Outlier Plot - Minimum Covariance Determinant Method")
set(gcf,'Position',[100 100 1120 840])
F = getframe(gcf);
[X, ~] = frame2im(F);
  3 个评论
Miles Brim
Miles Brim 2023-6-1
Technically it is jython. I beleive I am doing this correctly. On the application forum, It was suggested that MATLAB may be using antialiasing. Is there a way to capture the pixels after antialiasing?
The pixel array is passed by the MPS API to the other application.
I build the Buffered Image from the pixel array.
IMG=Result[5].get('mwdata')
IMGSize=Result[5].get('mwsize')
IMGType=Result[5].get('mwtype')
Img=[[[0, 0, 0] for i in range(IMGSize[1])] for j in range(IMGSize[0])]
n=-1
for k in range(IMGSize[2]):
for j in range(IMGSize[1]):
for i in range(IMGSize[0]):
n+=1
Img[i][j][k]=IMG[n]
image = BufferedImage(IMGSize[1], IMGSize[0], BufferedImage.TYPE_INT_RGB);
raster = image.getData();
sm = raster.getSampleModel();
writeRaster = Raster.createWritableRaster(sm,Point(0,0))
for i in range(IMGSize[1]):
for j in range(IMGSize[0]):
for k in range(IMGSize[2]):
writeRaster.setSample(i, j, k, Img[j][i][k])
image.setData(writeRaster);
event.source.parent.getComponent('Figure').putClientProperty('Picture',image)
I then display it accordingly:
image = event.source.getClientProperty("Picture")
if image:
canvasW = event.width
canvasH = event.height
imageW = image.getWidth()
imageH = image.getHeight()
scaleX = (canvasW-1.0) / imageW
scaleY = (canvasH-1.0) / imageH
g = event.graphics
g.scale(scaleX, scaleY)
g.drawImage(image,0,0,event.source)
Miles Brim
Miles Brim 2023-6-1
OK, yes, I know it is matlab: Here are the two images, one with graphics smoothing turned off.
fig.GraphicsSmoothing = 'off';

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by