Simply3DScan
Simple3DScan.TransformImage Class Reference

Does transformations of an image More...

Static Public Member Functions

static Blob[] GetBlobsFromGrayScaleBitmap (Bitmap bitmap)
 Gets the blobs from gray scale bitmap. More...
 
static Blob GetLargestBlob (IEnumerable< Blob > blobs)
 Gets the largest BLOB. More...
 
static float GetLaserLinePosition (Image laserImage, Filter filter)
 Gets the laser line position. More...
 
static float GetLaserLinePosition (Image grayImage)
 Gets the laser line position. More...
 
static float GetLaserLinePosition (Blob[] blobs)
 Gets the laser line position. More...
 
static Bitmap SimpleSkeletonizationImage (Bitmap bitmap)
 Skeletonization for image. More...
 
static Bitmap CannyEdgeImage (Bitmap bitmap)
 CannyEdge filters the image. More...
 
static Bitmap HomogenityEdgeDetectorImage (Bitmap bitmap)
 Homogenity edge detector for image. More...
 
static Bitmap SobelEdgeDetectorImage (Bitmap bitmap)
 Sobels edge detector for image. More...
 
static List< ColorPoint3DTransformStepImage (Image skeletonImage, Image colorImage, int step, bool microSteps, Information configuration)
 Transforms the step image. More...
 

Static Package Functions

static Bitmap CreateGrayImageOfLaser (Bitmap image, Filter filter)
 Creates the gray image of laser. More...
 
static List< Blob > ClearBlobs (Blob[] blobs, float laserLineX)
 Clears the blobs. Top < 100 in y is seen as only needed for laserline. Left > 100 in x are seen as outside of turntable Right < 950 in x are seen as outside of turntable. Down > 900 in y are seen as outside of turntable. Pixel left from lase cannot exist (obviously ;-) ) More...
 
static ColorPoint3D ConvertWorldPointToCameraPixel (this ColorPoint3D worldPoint, Information configuration)
 Converts the world point to camera pixel. More...
 
static ColorPoint3D ConvertCameraPixelToWorldPoint (this ColorPoint3D cameraPoint, Information configuration)
 Converts the camera pixel to world point. More...
 

Detailed Description

Does transformations of an image

Definition at line 18 of file TransformImage.cs.

Member Function Documentation

static Bitmap Simple3DScan.TransformImage.CannyEdgeImage ( Bitmap  bitmap)
static

CannyEdge filters the image.

Parameters
bitmapThe bitmap.
Returns

Definition at line 282 of file TransformImage.cs.

283  {
284  CannyEdgeDetector filter = new CannyEdgeDetector();
285  return ReturnFilteredImage(bitmap, filter);
286  }
static List<Blob> Simple3DScan.TransformImage.ClearBlobs ( Blob[]  blobs,
float  laserLineX 
)
staticpackage

Clears the blobs. Top < 100 in y is seen as only needed for laserline. Left > 100 in x are seen as outside of turntable Right < 950 in x are seen as outside of turntable. Down > 900 in y are seen as outside of turntable. Pixel left from lase cannot exist (obviously ;-) )

Parameters
blobsThe blobs.
laserLineXThe laser line x.
Returns
Exceptions
System.NotImplementedException

Definition at line 249 of file TransformImage.cs.

250  {
251  const float safetyFrame = 10f; // pixels directly near laser are seen as laserline
252 
253  return
254  blobs.Where(
255  blob =>
256  blob.CenterOfGravity.X > laserLineX + safetyFrame &&
257  // blob.CenterOfGravity.X > 100 && blob.CenterOfGravity.X < 950 &&
258  blob.CenterOfGravity.Y > 100 && blob.CenterOfGravity.Y < 860)
259  .ToList();
260  }

Here is the caller graph for this function:

static ColorPoint3D Simple3DScan.TransformImage.ConvertCameraPixelToWorldPoint ( this ColorPoint3D  cameraPoint,
Information  configuration 
)
staticpackage

Converts the camera pixel to world point.

Parameters
cameraPointThe camera point in pixel.
configurationThe configuration.
Returns
Camera point in cm

Definition at line 398 of file TransformImage.cs.

399  {
400  ColorPoint3D worldPoint = new ColorPoint3D(cameraPoint.X - configuration.Camera.Width / 2.0f,
401  cameraPoint.Y - configuration.Camera.Height * configuration.VisibleLimit.PercentFromTop / 100,
402  0);
403 
404  return new ColorPoint3D(worldPoint.X * configuration.Camera.WorldWidth / configuration.Camera.Width,
405  -worldPoint.Y * configuration.Camera.WorldHeight / configuration.Camera.Height,
406  0);
407  }
float WorldHeight
Gets the height of the world.
Definition: Camera.cs:60
Camera Camera
Gets or sets the camera.
Definition: Information.cs:24
double Y
Gets or sets the y.
Definition: ColorPoint3D.cs:23
float WorldWidth
Gets or sets the width of the world.
Definition: Camera.cs:53
double PercentFromTop
Gets or sets the percent from top.
Definition: Line.cs:33
double X
Gets or sets the x.
Definition: ColorPoint3D.cs:16
int Height
Gets or sets the height of the frame.
Definition: Camera.cs:46
Line VisibleLimit
Gets or sets the visible limit.
Definition: Information.cs:38
int Width
Gets or sets the width.
Definition: Camera.cs:38

Here is the caller graph for this function:

static ColorPoint3D Simple3DScan.TransformImage.ConvertWorldPointToCameraPixel ( this ColorPoint3D  worldPoint,
Information  configuration 
)
staticpackage

Converts the world point to camera pixel.

Parameters
worldPointThe world point.
configurationThe configuration.
Returns
Point in pixel

Definition at line 379 of file TransformImage.cs.

380  {
381  ColorPoint3D origin = new ColorPoint3D(configuration.Camera.Width / 2.0f,
382  configuration.Camera.Height * configuration.VisibleLimit.PercentFromTop / 100,
383  0);
384 
385  return new ColorPoint3D(worldPoint.X * configuration.Camera.Width / configuration.Camera.WorldWidth + origin.X,
386  -worldPoint.Y * configuration.Camera.Height / configuration.Camera.WorldHeight + origin.Y,
387  0);
388  }
float WorldHeight
Gets the height of the world.
Definition: Camera.cs:60
Camera Camera
Gets or sets the camera.
Definition: Information.cs:24
double Y
Gets or sets the y.
Definition: ColorPoint3D.cs:23
float WorldWidth
Gets or sets the width of the world.
Definition: Camera.cs:53
double PercentFromTop
Gets or sets the percent from top.
Definition: Line.cs:33
double X
Gets or sets the x.
Definition: ColorPoint3D.cs:16
int Height
Gets or sets the height of the frame.
Definition: Camera.cs:46
Line VisibleLimit
Gets or sets the visible limit.
Definition: Information.cs:38
int Width
Gets or sets the width.
Definition: Camera.cs:38
static Bitmap Simple3DScan.TransformImage.CreateGrayImageOfLaser ( Bitmap  image,
Filter  filter 
)
staticpackage

Creates the gray image of laser.

Parameters
imageThe image.
filterThe filter.
Returns
Exceptions
NotImplementedException

Definition at line 27 of file TransformImage.cs.

28  {
29  Bitmap filteredImage = (Bitmap) image.Clone();
30 
31  if (filter.UseHslFilter)
32  {
33  HSLFiltering hslFilter = new HSLFiltering
34  {
35  Saturation = new Range(filter.SaturationMin, filter.SaturationMax),
36  Luminance = new Range(filter.LuminanceMin, filter.LuminanceMax),
37  Hue = new IntRange(filter.HueMin, filter.HueMax)
38  };
39  hslFilter.ApplyInPlace(filteredImage);
40  }
41 
42  if (filter.UseColorFilter)
43  {
44  ColorFiltering colorFilter = new ColorFiltering
45  {
46  Red = new IntRange(filter.FilterRedMin, filter.FilterRedMax),
47  Blue = new IntRange(filter.FilterBlueMin, filter.FilterBlueMax),
48  Green = new IntRange(filter.FilterGreenMin, filter.FilterGreenMax)
49  };
50 
51  colorFilter.ApplyInPlace(filteredImage);
52  }
53 
54  IFilter grayFilter;
55 
56  switch (filter.GrayFilter)
57  {
58  case GrayFilter.BT709:
59  //RGB image to 8bpp gray scale
60  grayFilter = Grayscale.CommonAlgorithms.BT709;
61  break;
62  case GrayFilter.RMY:
63  grayFilter = Grayscale.CommonAlgorithms.RMY;
64  break;
65  case GrayFilter.Y:
66  grayFilter = Grayscale.CommonAlgorithms.Y;
67  break;
68  default:
69  //RGB image to 8bpp gray scale
70  grayFilter = Grayscale.CommonAlgorithms.BT709;
71  break;
72  }
73 
74  Bitmap grayImage = grayFilter.Apply(filteredImage);
75 
76  if (filter.UseThresholdFilter)
77  {
78  Threshold thresholdFilter = new Threshold(filter.Threshold);
79  thresholdFilter.ApplyInPlace(grayImage);
80  }
81 
82  if (filter.UseErosionFilter)
83  {
84  //erosion filter to filter out small unwanted pixels
85  Erosion3x3 errossionFilter = new Erosion3x3();
86  errossionFilter.ApplyInPlace(grayImage);
87  }
88 
89  if (filter.UseDiletationFilter)
90  {
91  //dilation filter
92  Dilatation3x3 dilatationFilter = new Dilatation3x3();
93  dilatationFilter.ApplyInPlace(grayImage);
94  }
95 
96  return grayImage;
97  }
int FilterGreenMax
Gets or sets the filter green maximum.
Definition: Filter.cs:88
float LuminanceMin
Gets or sets the luminance minimum.
Definition: Filter.cs:32
GrayFilter GrayFilter
Gets or sets the gray filter.
Definition: Filter.cs:109
int Threshold
Gets or sets the threshold.
Definition: Filter.cs:123
bool UseHslFilter
Gets or sets a value indicating whether [use HSL filter].
Definition: Filter.cs:11
bool UseThresholdFilter
Gets or sets a value indicating whether [use threshold filter].
Definition: Filter.cs:116
int FilterGreenMin
Gets or sets the filter green minimum.
Definition: Filter.cs:81
int FilterRedMin
Gets or sets the filter red minimum.
Definition: Filter.cs:67
int FilterBlueMax
Gets or sets the filter blue maximum.
Definition: Filter.cs:102
float LuminanceMax
Gets or sets the luminance maximum.
Definition: Filter.cs:39
int FilterRedMax
Gets or sets the filter red maximum.
Definition: Filter.cs:74
int HueMax
Gets or sets the hue maximum.
Definition: Filter.cs:53
bool UseDiletationFilter
Gets or sets a value indicating whether [use diletation filter].
Definition: Filter.cs:137
bool UseColorFilter
Gets or sets a value indicating whether [use color filter].
Definition: Filter.cs:60
int FilterBlueMin
Gets or sets the filter blue minimum.
Definition: Filter.cs:95
int HueMin
Gets or sets the hue minimum.
Definition: Filter.cs:46
float SaturationMax
Gets or sets the saturation maximum.
Definition: Filter.cs:25
float SaturationMin
Gets or sets the saturation minimum.
Definition: Filter.cs:18
bool UseErosionFilter
Gets or sets a value indicating whether [use erosion filter].
Definition: Filter.cs:130

Here is the caller graph for this function:

static Blob [] Simple3DScan.TransformImage.GetBlobsFromGrayScaleBitmap ( Bitmap  bitmap)
static

Gets the blobs from gray scale bitmap.

Parameters
bitmapThe bitmap.
Returns

Definition at line 151 of file TransformImage.cs.

152  {
153  BlobCounter blobCounter = new BlobCounter { ObjectsOrder = ObjectsOrder.YX };//MaxWidth = 10, ObjectsOrder = ObjectsOrder.YX };
154  blobCounter.ProcessImage(bitmap);
155  Blob[] blobs = blobCounter.GetObjectsInformation();
156  return blobs;
157  }

Here is the caller graph for this function:

static Blob Simple3DScan.TransformImage.GetLargestBlob ( IEnumerable< Blob >  blobs)
static

Gets the largest BLOB.

Parameters
blobsThe blobs.
Returns

Definition at line 166 of file TransformImage.cs.

167  {
168  int maxSize = 0;
169  Blob maxObject = new Blob(0, new Rectangle(0, 0, 0, 0));
170  foreach (Blob blob in blobs)
171  {
172  int blobSize = blob.Rectangle.Width * blob.Rectangle.Height;
173  if (blobSize <= maxSize)
174  continue;
175 
176  maxSize = blobSize;
177  maxObject = blob;
178  }
179 
180  return maxObject;
181  }
static float Simple3DScan.TransformImage.GetLaserLinePosition ( Image  laserImage,
Filter  filter 
)
static

Gets the laser line position.

Parameters
laserImageThe laser image.
filterThe filter.
Returns

Definition at line 191 of file TransformImage.cs.

192  {
193  Image grayImage = CreateGrayImageOfLaser((Bitmap)laserImage, filter);
194  Image skeletonImage = SimpleSkeletonizationImage((Bitmap)grayImage);
195  Blob[] blobs = GetBlobsFromGrayScaleBitmap((Bitmap)skeletonImage);
196  return GetLaserLinePosition(blobs);
197  }
static float GetLaserLinePosition(Image laserImage, Filter filter)
Gets the laser line position.
static Bitmap CreateGrayImageOfLaser(Bitmap image, Filter filter)
Creates the gray image of laser.
static Bitmap SimpleSkeletonizationImage(Bitmap bitmap)
Skeletonization for image.
static Blob[] GetBlobsFromGrayScaleBitmap(Bitmap bitmap)
Gets the blobs from gray scale bitmap.

Here is the call graph for this function:

Here is the caller graph for this function:

static float Simple3DScan.TransformImage.GetLaserLinePosition ( Image  grayImage)
static

Gets the laser line position.

Parameters
grayImageThe gray image.
Returns

Definition at line 206 of file TransformImage.cs.

207  {
208  Image skeletonImage = SimpleSkeletonizationImage((Bitmap)grayImage);
209  Blob[] blobs = GetBlobsFromGrayScaleBitmap((Bitmap)skeletonImage);
210  return GetLaserLinePosition(blobs);
211  }
static float GetLaserLinePosition(Image laserImage, Filter filter)
Gets the laser line position.
static Bitmap SimpleSkeletonizationImage(Bitmap bitmap)
Skeletonization for image.
static Blob[] GetBlobsFromGrayScaleBitmap(Bitmap bitmap)
Gets the blobs from gray scale bitmap.

Here is the call graph for this function:

static float Simple3DScan.TransformImage.GetLaserLinePosition ( Blob[]  blobs)
static

Gets the laser line position.

Parameters
blobsThe blobs.
Returns

Definition at line 220 of file TransformImage.cs.

221  {
222  // take laserlight from top 100 pixels and ignore lasers outside a valid range.
223  List<Blob> blobList =
224  blobs.Where(
225  blob => blob.CenterOfGravity.Y < 100)// && blob.CenterOfGravity.X > 100 && blob.CenterOfGravity.X < 800)
226  .ToList(); // also var blobList = ... would be possible. .ToList() prevents lazy evaluation and evaluates linq directly.
227  if (blobList.Count < 1)
228  blobList =
229  blobs.Where(
230  blob => blob.Rectangle.Y < 100)// && blob.CenterOfGravity.X > 100 && blob.CenterOfGravity.X < 800)
231  .ToList();
232  return blobList.Sum(blob => blob.CenterOfGravity.X) / blobList.Count;
233  }
static Bitmap Simple3DScan.TransformImage.HomogenityEdgeDetectorImage ( Bitmap  bitmap)
static

Homogenity edge detector for image.

Parameters
bitmapThe bitmap.
Returns

Definition at line 295 of file TransformImage.cs.

296  {
297  HomogenityEdgeDetector filter = new HomogenityEdgeDetector();
298  return ReturnFilteredImage(bitmap, filter);
299  }
static Bitmap Simple3DScan.TransformImage.SimpleSkeletonizationImage ( Bitmap  bitmap)
static

Skeletonization for image.

Parameters
bitmapThe bitmap.
Returns

Definition at line 269 of file TransformImage.cs.

270  {
271  SimpleSkeletonization filter = new SimpleSkeletonization();
272  return ReturnFilteredImage(bitmap, filter);
273  }

Here is the caller graph for this function:

static Bitmap Simple3DScan.TransformImage.SobelEdgeDetectorImage ( Bitmap  bitmap)
static

Sobels edge detector for image.

Parameters
bitmapThe bitmap.
Returns
Image with appleid SolidEdge-detection

Definition at line 308 of file TransformImage.cs.

309  {
310  SobelEdgeDetector filter = new SobelEdgeDetector();
311  return ReturnFilteredImage(bitmap, filter);
312  }
static List<ColorPoint3D> Simple3DScan.TransformImage.TransformStepImage ( Image  skeletonImage,
Image  colorImage,
int  step,
bool  microSteps,
Information  configuration 
)
static

Transforms the step image.

Parameters
skeletonImageThe skeleteon image.
colorImageThe color image.
stepThe step.
microStepsif set to true [micro steps].
configurationThe configuration.
Returns

Definition at line 333 of file TransformImage.cs.

334  {
335 
336  List<ColorPoint3D> points = new List<ColorPoint3D>();
337  Blob[] blobs = GetBlobsFromGrayScaleBitmap((Bitmap)skeletonImage);
338  float laserLineX = GetLaserLinePosition(blobs);
339 
340  ColorPoint3D worldCameraSourcePosition = new ColorPoint3D(configuration.Camera.WorldCoordinates.X,
341  configuration.Camera.WorldCoordinates.Y,
342  configuration.Camera.WorldCoordinates.Z);
343 
344  ColorPoint3D worldLaserSourcePosition = new ColorPoint3D(configuration.Laser.WorldCoordinates.X,
345  configuration.Laser.WorldCoordinates.Y,
346  configuration.Laser.WorldCoordinates.Z);
347 
348  ColorPoint3D worldLaserLinePosition = ConvertCameraPixelToWorldPoint(new ColorPoint3D(laserLineX, 0, 0), configuration);
349 
350  Line laserline = new Line(worldLaserSourcePosition, worldLaserLinePosition); // should stay the same
351 
352  // filter irrelevant blobs
353  List<Blob> relevantBlobs = ClearBlobs(blobs, laserLineX);
354 
355  foreach (Blob blob in relevantBlobs)
356  {
357  ColorPoint3D worldPoint = ComputeDepthByIntersection(blob, worldCameraSourcePosition, laserline, configuration);
358  worldPoint.Y = ScaleY(worldPoint, worldCameraSourcePosition);
359 
360  if (!AdjustPointToTurnTable(step, ref worldPoint, microSteps, configuration)) // adjust & test wether point is over turntable
361  continue;
362  worldPoint.Color = colorImage != null
363  ? ((Bitmap) colorImage).GetPixel((int)blob.CenterOfGravity.X, (int)blob.CenterOfGravity.Y)
364  : Color.White;
365  points.Add(worldPoint);
366  }
367 
368  return points;
369  }
Coordinates WorldCoordinates
Gets or sets the world coordinates.
Definition: Laser.cs:16
float Y
Gets or sets the y.
Definition: Coordinates.cs:21
Camera Camera
Gets or sets the camera.
Definition: Information.cs:24
static float GetLaserLinePosition(Image laserImage, Filter filter)
Gets the laser line position.
SharedObjects.Line Line
double Y
Gets or sets the y.
Definition: ColorPoint3D.cs:23
Laser Laser
Gets or sets the laser.
Definition: Information.cs:17
static ColorPoint3D ConvertCameraPixelToWorldPoint(this ColorPoint3D cameraPoint, Information configuration)
Converts the camera pixel to world point.
static List< Blob > ClearBlobs(Blob[] blobs, float laserLineX)
Clears the blobs. Top < 100 in y is seen as only needed for laserline. Left > 100 in x are seen as ou...
float Z
Gets or sets the z.
Definition: Coordinates.cs:28
float X
Gets or sets the x.
Definition: Coordinates.cs:14
Coordinates WorldCoordinates
Gets or sets the world coordinates.
Definition: Camera.cs:30
static Blob[] GetBlobsFromGrayScaleBitmap(Bitmap bitmap)
Gets the blobs from gray scale bitmap.

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: