LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

picture control pixelation

I am trying to laod an image into a picture control programatically, but the quality of the image is really poor. If I drag the same image onto the FP it looks great. This is a png with transparency. I've tried changing the transparency threshold of Read png File.vi, and this improves the picture's appearance, but makes it darker than the original png.

 

I have also played with the image zoom, but this has had no positive affect.

 

The image I'm using is sized to 150pixel high, so this is not a resizing issue either.

 

I'm guessing this is a limitation of the picture control, but boy is it annoying!

 

picture control vs dropped image.PNG

 

The image is a 32bit png. On the left you can see the picture control version, and on the right you can see the image dropped onto the VI FP.

 

LV2014

_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 1 of 9
(4,147 Views)

Please share your code and your image file. I've never had this issue with loading a PNG in to a Picture control.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 9
(4,130 Views)

Sure thing. (And neither have I, but I've never dealt with an image like this)

_____________
Creator of the BundleMagic plugin for LabVIEW!
Download All
0 Kudos
Message 3 of 9
(4,123 Views)

Where did the image come from?  Do you know what program created it?

 

PNG is a compressed file format, but is supposed to be lossless.  Perhaps LabVIEW is having issues decompressing it accurately relative to the algorithm used by the program that created it.

 

Maybe it is an issue with the transparency.  I opened the png in MS Paint and it looked okay.  I saved it as a BMP and it warned me about losing transparency. I used Read BMP file and it looked okay, except the background was white.  I tried to open in Paint and resave it as a PNG.  It again warned me about losing transparency.  Again, it opened up fine in LabVIEW but with the white background.

 

No explanationis, just observations.

0 Kudos
Message 4 of 9
(4,108 Views)

It seems like a limitation of the Read PNG File... I had the same observations as RavensFan.

 

If you mess around with the Transparency Threshold yo can get those gaps closed in, but it never looks like the original image. I think maybe the Read PNG File VI can't do partial transparency? It's either transparent or not?

test img Threshold.png

 

Edit: I did some research and I found this.

It seems to point to partial transparency as capable with PNG, but it then goes on to some stuff about masks and I got a bit confused.

Try messing around with this guy's VI. It's kinda complicated, but maybe you can make something out of it.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 5 of 9
(4,090 Views)

Ran out of time to edit my previous reply again. I found this post by Darin regarding partial transparency, but it doesn't seem to be functioning in my version of .NET.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 6 of 9
(4,064 Views)

Thanks for looking into it. It's not really important, but a curious problem.

_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 7 of 9
(4,023 Views)

It's simply because the Picture ctrl is toooo old, does NOT support alpha channel.

 

Try ActiveX, .Net, or IMAQ.

 

The only problem is that they all have an opaque background.

So you can't make your picture merge into the background.

 

 

George Zou
0 Kudos
Message 8 of 9
(3,990 Views)

@zou wrote:

It's simply because the Picture ctrl is toooo old, does NOT support alpha channel.

 

Try ActiveX, .Net, or IMAQ.

 

The only problem is that they all have an opaque background.

So you can't make your picture merge into the background.


While the picture control itself does not natively support partial transparency, it is possible to have it in the picture control. The basic idea is to grab an image of whatever is behind the picture control, then use the alpha value and the two color values to set the color of each pixel. This isn't a hard calculation (it's a scaled average of each of the RGB values using the alpha value as the scale), but it can get a bit annoying to write the code. I haven't looked at Darin's code in the other thread, but based on his text, it looks like he does do the averaging, but does skip the get-the-background phase and just uses a single BG color.

 

I don't know how all of that affects pixelation, though.


___________________
Try to take over the world!
0 Kudos
Message 9 of 9
(3,974 Views)