Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Image difference between Vision Control display & exported PNG File

Dear Sir/Madam:

hi, I am working on a function to export PNG file with NI VISION.

But the image looks so different between front panel (Vision control display) & exported PNG File(Windows Photo Viewer).

Exported png file image is more smooth ( less detailed)

 

I don't really know what the reason is, could anyone give me the advice?

 

PS: Image type is grayscale U8 for the vision control display.

The PNG file is created by " IMAQ Write Files 2 VI " with image quality 1000.

 

Thanks,

Eric Lu

0 Kudos
Message 1 of 9
(3,209 Views)

If you load the PNG back into Vision and display in an image display control, does it still look the same? It may just be re-sampling differences in the display output between the display control and Windows Photo Viewer (assuming it isn't viewed at a 1:1 zoom ratio).

0 Kudos
Message 2 of 9
(3,176 Views)

Thanks for the reply 😄

This image size is like 39xx & 38xx pixels, but we have image much bigger than that.

 

I have tried what you said, and you are correct.

I load the PNG file with NI Vision and get the same result (look different with other display).

I have also tried to load the png file with 2D picture, and it looks same as Windows Photo Viewer.

Is it possible to change the re-sampling differences with Vision Control display?

 

Thanks :DD

 

Regards,

Eric Lu

0 Kudos
Message 3 of 9
(3,164 Views)
I think maybe you are face with moire effect tray to zoom you image in labview and see if these difference change again in difference zoom
0 Kudos
Message 4 of 9
(3,157 Views)

Hi, it's been a while since the original post, but I am having a similar problem. I am capturing signed 16-bit PNG images and saving them with IMAQ Write File 2.vi. The image displayed on LabVIEW appears different when opening the same image with Windows Photo Viewer or IrfanView. It's more detailed in LabVIEW than in a 3rd party viewer. I don't think it's a moire effect, because I tried viewing the images at 100% zoom, and the differences are still present.

 

Is it possible that the LabVIEW display has different brightness/contrast settings? I tried adjusting the brightness and contrast of the PNG image within IrfanView, and I was able to make it appear closely to how it is displayed in LabVIEW.

0 Kudos
Message 5 of 9
(2,457 Views)

From the IMAQ Write File 2 for png:

 

Use bit depth? (false) When saving a signed 16-bit image to a PNG file, NI Vision must convert the data to an unsigned format and shift the data so that most significant bit is always the leftmost bit. Set this parameter to TRUE to use the bit depth information attached to the image to perform these conversions. Set this parameter to FALSE to bias the image by adding a constant value to all the pixels in the image such that the lowest negative pixel value in the image maps to zero, and then shifting the image data based on the highest pixel value in the image. The default is FALSE.

 

EDIT: Try setting that parameter to True and see if the images then appear similar.

-AK2DM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 6 of 9
(2,453 Views)

I've had the same issue last week, and the "Use bit depth" flag does not seem to make any difference - files are identical with or without that flag set.  In either case it appears that for 16-bit PNGs, NI Vision rescales images in powers of two according to the image maximum.  For example, the attached code (LV 2018) creates two images, one with a maximum of just under 8192, and one just over.  The saved values were roughly a factor of two different - the first image reaches 65535, and the second only just over 32768.  When NI Vision reads the same file in again, it converts back to the original values, so if only using LabVIEW, there does not appear to be any issue - it's only when looking at the files with another software (I used ImageJ).

 

I would file this as a bug, and suggest that Write File should write the values exactly as contained in the image.

PNG_U16.png

Message 7 of 9
(2,450 Views)

I don't have that specific IMAQ vi with the paintbucket glyph, so I can't replicate the issue for myself. It's probably part of the Vision Development Module, while I only have the Vision Acquisition Software.

 

Regardless, is the main issue the IMAQ Write File 2.vi not saving the image correctly, or is it the "Image Out" wire output that is not displaying the image correctly? What is the "original" image, the one viewed through a third-party viewer, or the one that is opened with LabVIEW?

0 Kudos
Message 8 of 9
(2,432 Views)

Good questions!  Firstly, the "paint bucket" just fills the image with the given value, so the top image is filled with 8191 and the lower image with 8193.  The two images saved as PNGs from the top image contain 65535 (so it is multiplied by ~8) and the two from the lower image contain 32774 (multiplied by ~4) - at least they do according to ImageJ.  When reading back into LabVIEW, they once again contain 8191 and 8193.

 

So, it seems that IMAQ Write File and IMAQ Read File work together properly, however if the image is to be read by some other software, then the values will not match.  I cannot see any reason not to write the true values (8191 and 8193) as happens when using IMAQ Write File to write a TIFF, so I would class it as a bug in IMAQ Write File.

0 Kudos
Message 9 of 9
(2,421 Views)