Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

C# - How to check if image is black/very dark

Yes, i have GetPixelValue for

private NationalInstruments.CWIMAQControls.AxCWIMAQVision axCWIMAQVision1;

 

0 Kudos
Message 11 of 14
(1,799 Views)

Hello,

 

I am just guessing here, but this should then be an overloaded function. So if you have an 8-bit image, the prototype should look something like this:

 

uint8_t GetPixelValue(IMAQ image, int u, int v); // also incudes some error?

 

I just taking a guess here, since I don't have acces to Labview right now.

 

So you could probably do something like this:

 

double YOUR_FUNCTION(IMAQ image, int yT, int xL, int yB, int xR) {

uint8_t tmp;
unsigned long int sum = 0;
double average; for(int j=yT;j<=yB;j++) {
for(int i=xL;i<=xR;i++) {
tmp = GetPixelValue(image,i,j); sum += (unsigned long int) tmp;
} }
average = (double) sum/(double)((xR-xL)*(yB-yT)); return average;
}

 

Where xL, xR, yT and yB are the top-left and bottom right coordinates of your ROI (mask).

 

This approach would be slower than pointer operation shown before.

 

I hope this helps in some way.

 

Best regards,

K

 

 


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 12 of 14
(1,790 Views)

Hello,

 

I was wrong, the function prototype looks like:

 

void  LV_GetPixelValue_v2(void *image, int32_t x, int32_t y, uint8_t *u8Pixel, uint16_t *u16Pixel, int16_t *i16Pixel, float *sglPixel, void *err);

 

So you would need to use the referenece operator (&):

 

uint8_t pixelValue;

.

.

.

 

void  LV_GetPixelValue_v2(void *image, int32_t x, int32_t y, &pixelValue, uint16_t *u16Pixel, int16_t *i16Pixel, float *sglPixel, void *err);

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 13 of 14
(1,782 Views)

I think counterpart for LabVIEW function "IMAQ Quantify" is in .NET available.

  • QuantifyReport

    public sealed class QuantifyReport
        Member of NationalInstruments.Vision.Analysis

    Summary:
    A collection of NationalInstruments.Vision.Analysis.QuantifyReportItem objects. It contains one item for each region supplied to the NationalInstruments.Vision.Analysis.Algorithms.Quantify(NationalInstruments.Vision.VisionImage) method.


    I don't know how to use it. Is there any example?
0 Kudos
Message 14 of 14
(1,761 Views)