LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

range the pixel value between 0~255 and generate a grey image

Solved!
Go to solution

Hello, 

I am trying to write a laser scanning imaging code and the front panel can show the image at each iteration. But when I save this scanned image to an png file, it is an black image. I guess it is because the average value of each pixel is below 1. How can I fix this issue when saving an grey image with pixel value range from 0~255? I did not find histogram function in my Labview-Vision&Motion panel. 

Thank you very much

Yu

Download All
0 Kudos
Message 1 of 6
(4,689 Views)

Hello, 

In the process of normalize the array pixel value during 0~255, I add this code in my program. But once I add the calculation the system cannot save png image and shows error as attached. How can I fix this problem?

Thank you

Yu

Download All
0 Kudos
Message 2 of 6
(4,666 Views)
Solution
Accepted by topic author Rhapsody16

Hi Yu,

 


@Rhapsody16 wrote:

In the process of normalize the array pixel value during 0~255, I add this code in my program. But once I add the calculation the system cannot save png image and shows error as attached. How can I fix this problem?


Why do you scale the whole cluster you get from that FlattenPixmap function?

Why don't you scale your "raw" image data?

Why don't you notice those red coercion dots?

Why don't you attach the latest VI? We cannot debug/edit/run images with LabVIEW!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 6
(4,657 Views)

Dear GerdW,

Sorry for not attaching the old version and I have already reuploaded the 2012 version code. 

I scale the whole cluster because I think it may not reduce the speed inside the loop. And I need to calculate the max and minimum values of whole image and scale them to 0~255 so I scale them outside the loop.

I noticed the red coercion dots after your mention. But I don't know what does it means and how to fix them.

Would you please help me about this?

Thank you very much

Best regards

Yu

0 Kudos
Message 4 of 6
(4,644 Views)
Solution
Accepted by topic author Rhapsody16

Hi Yu,

 

don't scale the whole cluster, but only scale the raw data:

(You can delete those two functions before the WritePNG…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(4,639 Views)

Hi, GerdW,

Thank you for the modified code. 

I will try to save the image again in the lab tomorrow.

Thank you!

Best regards

Yu

0 Kudos
Message 6 of 6
(4,629 Views)