i want to run this source code but i can't;
here is code URL:
http://www.oliveragustin.com/background-subtraction-in-c-part-2/
and it's the source code :
var image = new Image
// threshold values for each channel
var thresholds = new[] { new TRange
Image
// threshold each channel
for (int i = 0; i < 3; i++)
{
grays[i]._ThresholdToZero(new Gray(thresholds[i].LowerValue));
grays[i]._ThresholdToZeroInv(new Gray(thresholds[i].UpperValue));
grays[i]._ThresholdBinary(new Gray(1), new Gray(255));
}
// merge the thresholded array of binary images above
var mask = grays[0].And(grays[1].And(grays[2]));
// result
var resultImage = image.Copy(mask);
my problem is this line :
var thresholds = new [] {new TRange
i don't know how must i define above line in c#! what is TRange? i defined it like the following code but it has error
"Object reference not set to an instance of an object";
public struct TRange
{
public int LowerValue, UpperValue;
public TRange(int x, int y)
{
LowerValue = x;
UpperValue = y;
}
}
// background subtraction in NewBGSubtraction
private void NewBGSubtraction(Bitmap filename, bool displayResult)
{
var image = new Image(filename);
// threshold values for each channel
var thresholds = new[] {new TRange(70, 255), new TRange(0, 255), new TRange(0, 255) };
Image[] grays = image.Convert().Split();
// threshold each channel
for (int i = 0; i < 3; i++)
{
grays[i]._ThresholdToZero(new Gray(thresholds[i].LowerValue));
grays[i]._ThresholdToZeroInv(new Gray(thresholds[i].UpperValue));
grays[i]._ThresholdBinary(new Gray(1), new Gray(255));
}
// merge the thresholded array of binary images above
var mask = grays[0].And(grays[1].And(grays[2]));
// result
var resultImage = image.Copy(mask);
pictureBox2.Image = resultImage.Bitmap;
}
livePosted Apr 23, 2013, 7:43 PM
I am trying to implement the same piece of code but it doesn't work.
Can you send me your program?
I did this..
my email: [email protected]! Thanks
Bahar JalaliPosted Jun 5, 2012, 3:32 AM
Bahar JalaliPosted Jun 5, 2012, 3:23 AM
VulpesPosted Jun 4, 2012, 12:52 PM
http://www.oliveragustin.com/tag/background-subtraction/