uiimage introduces artifacts? How to fix?
1 view (last 30 days)
Show older comments
Jamie on 26 Jan 2021
Commented: Nitin Kapgate on 11 Feb 2021
I am building an application using App Designer and I am using images (Type = 'uiimage') and using the ImageSource property to display data. I am seeing artifacts on the GUI that are not in my data.
I can also produce the same behavior with a plain uiimage from the console.
img = ones(160, 160, 3, 'uint8') * 128;
img([48, 65], 1:4:end, :) = 0;
img([48, 65], 2:4:end, :) = 0;
fig = uifigure;
im = uiimage(fig);
im.ImageSource = img;
im.Position = [ 100, 100, 160, 160];
im.ScaleMethod = 'none';
The result from this is shown here:
Looking closely at the dashed lines shows the artifacts:
These look to me like jpeg artifacts. I am using ScaleMethod 'none' to try to rule out any resampling effects. In my application I am using a fixed size image that exactly matches the data size so it should not be performing scaling.
One of the purposes of my application is for users to closely scrutinize an image to look for artifacts in the underlying data, so it is important that the MxNx3 uint8 array is faithfully produced on the screen.
A "regular" figure with imshow does not show artifacts:
fig2 = figure;
What's the best way to show the image in my application without artifacts?
Nitin Kapgate on 10 Feb 2021
Edited: Nitin Kapgate on 10 Feb 2021
Thank you @Jamie for bringing the issue of artifacts in the uifigure + uiimage workflow to my attention.
After revisiting the issue again, I could see artifacts being displayed when the image is displayed using the uifigure + uiimage workflow.
I have brought this issue to the concerned people and the issue might be resolved in future releases.
Nitin Kapgate on 11 Feb 2021
As a workaround, you can serve cdata as file:
im.ImageSource = 'imgFile.png'
More Answers (0)
Find more on Develop uifigure-Based Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!