40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Some filters for Potrace in Inkscape
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Bob Jamison <rjamison@titan.com>
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Stéphane Gimenez <dev@gim.name>
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Copyright (C) 2004-2006 Authors
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Released under GNU GPL, read the file 'COPYING' for more information
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński/*#########################################################################
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński### G A U S S I A N (smoothing)
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński#########################################################################*/
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński GrayMap *newGm = GrayMapCreate(width, height);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński for (int y = 0 ; y<height ; y++)
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński for (int x = 0 ; x<width ; x++)
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński /* image boundaries */
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński if (x<firstX || x>lastX || y<firstY || y>lastY)
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński newGm->setPixel(newGm, x, y, me->getPixel(me, x, y));
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński /* all other pixels */
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński RgbMap *newGm = RgbMapCreate(width, height);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński for (int y = 0 ; y<height ; y++)
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński for (int x = 0 ; x<width ; x++)
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński /* image boundaries */
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński if (x<firstX || x>lastX || y<firstY || y>lastY)
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński newGm->setPixelRGB(newGm, x, y, me->getPixel(me, x, y));
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński /* all other pixels */
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński/*#########################################################################
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński### C A N N Y E D G E D E T E C T I O N
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński#########################################################################*/
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Perform Sobel convolution on a GrayMap
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński double dLowThreshold, double dHighThreshold)
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński GrayMap *newGm = GrayMapCreate(width, height);
return NULL;
for (int y = 0 ; y<height ; y++)
for (int x = 0 ; x<width ; x++)
sum = 0;
sobelIndex = 0;
if (sumX==0)
if (sumY==0)
else if (sumY<0)
int edgeDirection = 0;
edgeDirection = 0;
if (sumX==0)
if (sumY!=0)
if (edgeDirection == 0)
sum = 0;
sum = 0;
return newGm;
GrayMap *
if (!gm)
return NULL;
if (!cannyGm)
return NULL;
return cannyGm;
sum = 0;
return gm;