44 #include <Base/Image/Image.hh>
45 #include <Base/Image/ImageIO.hh>
46 #include <Base/ImageUtils/ImageDraw.hh>
48 #include <Base/Geometry/HomgPoint2D.hh>
49 #include <Base/Geometry/HomgPoint3D.hh>
50 #include <Geometry/RMatrix.hh>
51 #include <Geometry/Conic2D.hh>
72 bool ConicGetStartPoint(
const Conic2D &conic,
73 unsigned int imageWidth,
unsigned int imageHeight,
90 register int initialSign;
91 int initialSign1, initialSign2;
96 p2[1] = imageHeight - 1;
114 for (
register unsigned int x = 1; x < imageWidth; x++) {
118 if (dist < 0.0 && initialSign1 > 0) {
119 startPoint = ConicMinDist(conic,
HomgPoint2D(x - 1, 0), p1);
122 if (dist > 0.0 && initialSign1 < 0) {
123 startPoint = ConicMinDist(conic,
HomgPoint2D(x - 1, 0), p1);
127 startPoint = ConicMinDist(conic,
HomgPoint2D(x - 1, 0), p1);
134 if (dist < 0.0 && initialSign2 > 0) {
135 startPoint = ConicMinDist(conic,
HomgPoint2D(x - 1, imageHeight - 1), p2);
138 if (dist > 0.0 && initialSign2 < 0) {
139 startPoint = ConicMinDist(conic,
HomgPoint2D(x - 1, imageHeight - 1), p2);
143 startPoint = ConicMinDist(conic,
HomgPoint2D(x - 1, imageHeight - 1), p2);
150 p2[0] = imageWidth - 1;
168 for (
register unsigned int y = 1; y < imageHeight; y++) {
172 if (dist < 0.0 && initialSign1 > 0) {
173 startPoint = ConicMinDist(conic,
HomgPoint2D(0, y), p1);
176 if (dist > 0.0 && initialSign1 < 0) {
177 startPoint = ConicMinDist(conic,
HomgPoint2D(0, y), p1);
181 startPoint = ConicMinDist(conic,
HomgPoint2D(0, y), p1);
188 if (dist < 0.0 && initialSign2 > 0) {
189 startPoint = ConicMinDist(conic,
HomgPoint2D(imageWidth - 1, y), p2);
192 if (dist > 0.0 && initialSign2 < 0) {
193 startPoint = ConicMinDist(conic,
HomgPoint2D(imageWidth - 1, y), p2);
197 startPoint = ConicMinDist(conic,
HomgPoint2D(imageWidth - 1, y), p2);
203 for (
register unsigned int y = 0; y < imageHeight; y++) {
214 for (
register unsigned int x = 0; x < imageWidth; x++) {
218 if (dist < 0.0 && initialSign > 0) {
219 startPoint = ConicMinDist(conic,
HomgPoint2D(x - 1, y), p);
222 if (dist > 0.0 && initialSign < 0) {
223 startPoint = ConicMinDist(conic,
HomgPoint2D(x - 1, y), p);
227 startPoint = ConicMinDist(conic,
HomgPoint2D(x - 1, y), p);
235 for (
register unsigned int x = 0; x < imageWidth; x++) {
246 for (
register unsigned int y = 0; y < imageWidth; y++) {
250 if (dist < 0.0 && initialSign > 0) {
251 startPoint = ConicMinDist(conic,
HomgPoint2D(x, y - 1), p);
254 if (dist > 0.0 && initialSign < 0) {
255 startPoint = ConicMinDist(conic,
HomgPoint2D(x, y - 1), p);
259 startPoint = ConicMinDist(conic,
HomgPoint2D(x, y - 1), p);
273 const unsigned int x = (
unsigned int)rint(p[0]);
274 const unsigned int y = (
unsigned int)rint(p[1]);
280 pImageData[offset + c] = 255;
285 bool ConicGetNextPoint(
const Conic2D &conic,
294 bool pUnvisited, qUnvisited;
298 cout <<
"getting next point" << endl;
301 for (
int y = -1; y <= 1; y++) {
302 for (
int x = -1; x <= 1; x++) {
303 p[0] = curPoint[0] + x;
304 p[1] = curPoint[1] + y;
315 pVisitedPoints[(
unsigned int)p[0]][(
unsigned int)p[1]] == 0;
317 pVisitedPoints[(
unsigned int)q[0]][(
unsigned int)q[1]] == 0;
319 if (distP == 0.0 && pUnvisited) {
323 if (distQ == 0.0 && qUnvisited) {
327 if ((distP < 0.0 && distQ > 0.0) || (distP > 0.0 && distQ < 0.0)) {
328 if (pUnvisited && qUnvisited) {
329 nextPoint = ConicMinDist(conic, p, q);
344 pVisitedPoints[(
unsigned int)p[0]][(
unsigned int)p[1]] == 0;
346 pVisitedPoints[(
unsigned int)q[0]][(
unsigned int)q[1]] == 0;
348 if (distP == 0.0 && pUnvisited) {
352 if (distQ == 0.0 && qUnvisited) {
356 if ((distP < 0.0 && distQ > 0.0) || (distP > 0.0 && distQ < 0.0)) {
357 if (pUnvisited && qUnvisited) {
358 nextPoint = ConicMinDist(conic, p, q);
383 cout << endl <<
"got start point " << curPoint << endl;
385 ConicShadePixel(image, curPoint);
386 pVisitedPoints[(
unsigned int)curPoint[0]][(
unsigned int)curPoint[1]] = 1;
389 lastPoint = curPoint;
390 while (ConicGetNextPoint(conic, visitedPoints, lastPoint, curPoint)) {
391 cout <<
"got next point " << curPoint << endl;
393 ConicShadePixel(image, curPoint);
394 pVisitedPoints[(
unsigned int)curPoint[0]][(
unsigned int)curPoint[1]] = 1;
395 lastPoint = curPoint;
406 int main(
int argc,
char** argv) {
420 DrawConic(image, conic);
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
HomgPoint2D & Homogenize()
homogenize class data member elements to W==1 by divison by W
void SetEllipse(const HomgPoint2D &Center, const double &dAngle, const double &radius_a, const double &radius_b)
construct an ellipse with explicit parameters
unsigned int GetWidth() const
double LocatePoint(const HomgPoint2D &point2D) const
determines if the point is inside/on/outside the conic
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
unsigned int GetHeight() const
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
void Draw(Image< unsigned char > &img) const
draws conic into an image using a brute force method
A 3x3 matrix representing a conic (cone/plane intersection)
void SetZero()
zeroes the image
class BIASGeometryBase_EXPORT HomgPoint2D
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase