LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

different histogram in labview and matlab.


@Shredderofmass2 wrote:

The question is explicit and explained here more than once in great detail. You don't have an answer or even an idea. And yet you post again with a non answer.


Uhhhh,  they are two different people.

0 Kudos
Message 31 of 43
(1,499 Views)

The image looks right in paint. I tried saving as a 24 bit BMP and a couple other formats. Paint scaled it down to an 8 bit image which appeared to be scaled well. 

 

1) Save Data from a 12 bit camera. Saved with Labview vision 2015 as a U16 image.

2) Open with Labview. Perfect o to 4095 values.

3) Open with paint. Looks good. Save as a 24 bit BMP. Paint scales it down to an 8 bit. But its paint so I didn't expect much.

4) Open it in Matlab. Matlab scales it to full dynamic range of 16 bits. I cannot trust any scaling because slight nuances in the image matter, scaling and camera gain are critical parts of the experiment.

 

I am hoping that there is a way to either change the Labview saving such that it works well with matlab or find the secret code in Matlab to get it right.

 

I guess I will download GIMP to see what that does.

Thanks

0 Kudos
Message 32 of 43
(1,496 Views)

@RavensFan wrote:

@Shredderofmass2 wrote:

The question is explicit and explained here more than once in great detail. You don't have an answer or even an idea. And yet you post again with a non answer.


Uhhhh,  they are two different people.


And from 9+ years ago...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 33 of 43
(1,495 Views)

Yeah,

I caught that. One had a suggestion the other did not.

Thanks

0 Kudos
Message 34 of 43
(1,494 Views)

@Shredderofmass2 wrote:

The image looks right in paint. I tried saving as a 24 bit BMP and a couple other formats. Paint scaled it down to an 8 bit image which appeared to be scaled well. 

 

1) Save Data from a 12 bit camera. Saved with Labview vision 2015 as a U16 image.

2) Open with Labview. Perfect o to 4095 values.

3) Open with paint. Looks good. Save as a 24 bit BMP. Paint scales it down to an 8 bit. But its paint so I didn't expect much.

4) Open it in Matlab. Matlab scales it to full dynamic range of 16 bits. I cannot trust any scaling because slight nuances in the image matter, scaling and camera gain are critical parts of the experiment.

 

I am hoping that there is a way to either change the Labview saving such that it works well with matlab or find the secret code in Matlab to get it right.

 

I guess I will download GIMP to see what that does.

Thanks


So if everything you are looking at is showing that LabVIEW is working fine and Matlab has the problem, why do you expect that something should change in LabVIEW to fix the Matlab problem?

0 Kudos
Message 35 of 43
(1,484 Views)

This original discussion is 9 years and a lot of things have probably changed, both in LabVIEW and Matlab. There is a CAR listed above somewhere. Contact NI to see what the status is. We cannot help you with that.

0 Kudos
Message 36 of 43
(1,465 Views)

@RavensFan wrote:

@Shredderofmass2 wrote:

The image looks right in paint. I tried saving as a 24 bit BMP and a couple other formats. Paint scaled it down to an 8 bit image which appeared to be scaled well. 

 

1) Save Data from a 12 bit camera. Saved with Labview vision 2015 as a U16 image.

2) Open with Labview. Perfect o to 4095 values.

 


So if everything you are looking at is showing that LabVIEW is working fine and Matlab has the problem, why do you expect that something should change in LabVIEW to fix the Matlab problem?


Agreed, I don't see an issue here with LV.  LV saves it perfectly.  There isn't much else that LV can do to help you.  When you read it with MATLAB then it "adjusts" the image.  You need to find out how to read raw image without scaling in MATLAB and folks here can't help you with that.  This doesn't sound like exactly a bug in LV which is doing what you expect and what you want.

 

Other 3rd party utilities can't help if MATLAB is going to rescale the image and give you not the raw data that you want.

LabVIEW ChampionLabVIEW Channel Wires

0 Kudos
Message 37 of 43
(1,454 Views)

I found the best workaround is to save as jp2 instead of png in LabVIEW. It is also lossless, supports 16bit data and it avoids the different interpretations of the png spec between NI and others like Mathworks.

Message 38 of 43
(1,438 Views)

I found the best workaround is to save as jp2 instead of png in LabVIEW. It is also lossless, supports 16bit data and it avoids the different interpretations of the png spec between NI and others like Mathworks.

 

That sounds promising.  I am going to fire up matlab and give that a try.

 

The lossless compression is important, these data sets get huge. Even shaving 25% from the total volume is a big advantage.

 

0 Kudos
Message 39 of 43
(1,415 Views)
Yes i use it to save u16 images between LabVIEW and Matlab. If file size is an issue you can of course choose to not make use of the lossless option and compress more aggressively. But then you may as well use u8 images i suppose.
A snag with jp2 is that windows doesnt have a default viewer for it so in explorer you wont see thumbnail previews. What i do especially for large files is to also save a much compressed u8 jpg version (scaled to 255 of course) of the image into the same folder. This makes it easy and quick to view the images for debugging purposes. But this is up to you.
Without opening a can of worms i should say that many years ago and several posts earlier on this thread, i believe i determined that it was LabVIEW at fault: that version was unnecessarily scaling u16 images when saving to png, and unscaling when loading png. Not sure if that is still the case but anyway using jp2 makes this a non-issue.
 
 
0 Kudos
Message 40 of 43
(1,394 Views)