01-31-2006 04:10 PM
02-01-2006 02:09 PM
Hi tres0422,
You are indexing an object that has not been initialized with the line HistogramReport.Item(0). This results in your Invalid Index runtime error. When you call Dim HistogramReport As New CWIMAQHistogramReport the resulting object has zero items. You will need to add an object using HistogramReport.Add before you try to reference it in memory.
Regards,
Ryan F.
02-01-2006 04:09 PM
Ryan I totally appreciate your help. Thank you. I tried the histogramreport.add, but it didn't work. I changed the ".item(0)" to an ".item(1). Now I am getting another error. "Run-Time Error 31006. The Image is not large enough for the operation." My concern is that I have not attached an image to the variable named image or that .item(1) is empty. Can't tell which, any ideas?
Thanks, Thomas
02-02-2006 10:14 AM
02-02-2006 01:32 PM - edited 02-02-2006 01:32 PM
Ryan,
Here is the code.
Thomas
Private Sub Convert_click()
Dim imGrab As New CWIMAQImage
Dim ImageType As CWIMAQImageTypes
Dim HistogramReport As New CWIMAQHistogramReport
Dim Value As Double
ImageType = cwimaqImageTypeU8
'*****intSnapIndex is a public variable that is equal to the index number of the last valid Image Acquisition
Set imGrab = CWIMAQ1.Images(intSnapIndex)
'***** Start of code created by builder file from Vision Assistant
CWIMAQVision1.Cast imGrab, imGrab, cwimaqImageTypeSGL
CWIMAQVision1.Histogram2 imGrab, HistogramReport
CWIMAQVision1.Subtract imGrab, HistogramReport.Item(1).PixelRange.Min, imGrab
Value = IIf(ImageType = cwimaqImageTypeI16, 32677, 255) _
/ (HistogramReport.Item(1).PixelRange.Max - _
HistogramReport.Item(1).PixelRange.Min)
CWIMAQVision1.Multiply imGrab, Value, imGrab
CWIMAQVision1.Cast imGrab, imGrab, ImageType
CWIMAQViewer1.Palette.Type = cwimaqPaletteGrayScale
'***** End of code created by builder filer from Vision Assistant
strfileext = "JPEG"
Call Save_Click
End Sub
Message Edited by tres0422 on 02-02-2006 01:37 PM
02-02-2006 01:40 PM
Thanks a lot Thomas. Good luck in your application,
Ryan F.