• Aucun résultat trouvé

Computations on images

Dans le document The Npic library Reference Manual (Page 28-33)

1.5.1 Comparison of pixels Sources: calc diff.h , calc diff.c .

• NpicCompare

int NpicCompare (Npic_image *np1, Npic_image *np2, int n);

Compare two images, pixel per pixel (border pixels excluded).

Return<0 if images are not ok, or do not have same type and size, 0 if same pixel values,

>0 the number of pixels which differ.

Print at most ndifferences. Verbose.

• NpicCompareBin

int NpicCompareBin (Npic_image *np1, Npic_image *np2, int n);

The same, but compare pixel binary values (== 0 or != 0).

1.5.2 Changing values

Sources: calc values.h , calc values.c .

The following functions do not modify border pixels; they do nothing ifnp is not ok, set not ok on error, and are verbose.

Depending on image type, use function ifor integer pixels, function dfor double pixels, function qfor 4 short pixels.

• NpicFillVal *

1.5. COMPUTATIONS ON IMAGES 29 void NpicFillVal_i (Npic_image *np, int val1);

void NpicFillVal_d (Npic_image *np, double val1);

void NpicFillVal_q (Npic_image *np, int a, int b, int c, int d);

Set all pixels to the value val1.

• NpicChangeVal *

void NpicChangeVal_i (Npic_image *np, int val1, int val2);

void NpicChangeVal_d (Npic_image *np, double val1, double val2);

void NpicChangeVal_q (Npic_image *np, int a1, int b1, int c1, int d1, int a2, int b2, int c2, int d2);

Set each pixel having value val1to the valueval2.

• NpicExchangeVal *

void NpicExchangeVal_i (Npic_image *np, int val1, int val2);

void NpicExchangeVal_d (Npic_image *np, double val1, double val2);

void NpicExchangeVal_q (Npic_image *np, int a1, int b1, int c1, int d1, int a2, int b2, int c2, int d2);

Set each pixel having value val1to the valueval2, and vice versa.

• NpicMin/MaxValue

double NpicMaxValue (Npic_image *np1);

double NpicMinValue (Npic_image *np1);

Return the max or min of pixels values in image interior.

1.5.3 Thresholding pixel values Sources: calc threshold.h , calc threshold.c .

The following functions do not modify border pixels; they do nothing if np is not ok, set not ok on error, and are verbose.

Depending on image type, use functioni for integer pixels, function dfor double pixels, function qfor 4 short pixels.

• NpicThresholdLT *

void NpicThresholdLT_i (Npic_image *np, int val1, int val2);

void NpicThresholdLT_d (Npic_image *np, double val1, double val2);

void NpicThresholdLT_q (Npic_image *np, int a1, int b1, int c1, int d1, int a2, int b2, int c2, int d2);

Set each pixel having value < val1to the valueval2.

• NpicThresholdLE *

void NpicThresholdLE_i (Npic_image *np, int val1, int val2);

void NpicThresholdLE_d (Npic_image *np, double val1, double val2);

void NpicThresholdLE_q (Npic_image *np, int a1, int b1, int c1, int d1, int a2, int b2, int c2, int d2);

Set each pixel having value <= val1to the value val2.

• NpicThresholdGT *

void NpicThresholdGT_i (Npic_image *np, int val1, int val2);

void NpicThresholdGT_d (Npic_image *np, double val1, double val2);

void NpicThresholdGT_q (Npic_image *np, int a1, int b1, int c1, int d1, int a2, int b2, int c2, int d2);

Set each pixel having value > val1to the valueval2.

• NpicThresholdGE *

void NpicThresholdGE_i (Npic_image *np, int val1, int val2);

void NpicThresholdGE_d (Npic_image *np, double val1, double val2);

void NpicThresholdGE_q (Npic_image *np, int a1, int b1, int c1, int d1, int a2, int b2, int c2, int d2);

Set each pixel having value >= val1to the value val2.

1.5.4 Summing images Sources: calc algeb.h , calc algeb.c .

The following functions do not modify border pixels. The images must have same type and size; they can have same address in memory.

The functions do nothing if one of the image is not ok; they set not ok fordeston error, and are verbose.

• NpicLinearSum

void NpicLinearSum (Npic_image *dest, Npic_image *src1, double c1, double c2);

Set each pixel ofdestto a linear combination of corresponding pixels insrc1: dest := src1 * c1 + c2.

• NpicBilinearSum

void NpicBilinearSum (Npic_image *dest, Npic_image *src1, Npic_image *src2, double c1, double c2, double c3);

Set each pixel of destto a linear combination of corresponding pixels insrc1and src2: dest := src1 * c1 + src2 * c2 + c3 .

• NpicTrilinearSum

1.5. COMPUTATIONS ON IMAGES 31 void NpicTrilinearSum (Npic_image *dest, Npic_image *src1, Npic_image *src2,

Npic_image *src3, double c1, double c2, double c3, double c4);

Set each pixel of destto a linear combination of corresponding pixels in src1,src2and src3:

dest := src1 * c1 + src2 * c2 + src3 * c3 + c4 .

• NpicQuadraticSum

void NpicQuadraticSum (Npic_image *dest, Npic_image *src1, double c1, double c2, double c3);

Set each pixel ofdestto a quadratic combination of corresponding pixels in src1: dest := src1^2 * c1 + src1 * c2 + c3.

• NpicBiQuadraticSum

void NpicBiQuadraticSum (Npic_image *dest, Npic_image *src1, Npic_image *src2, double c1, double c2, double c3, double c4, double c5);

Set each pixel of dest to a quadratic combination of corresponding pixels in src1 and src2:

dest := src1^2 * c1 + src1 * c2 + src2^2 * c3 + src2 * c4 + c5 . 1.5.5 Drawing into images

Sources: calc draw.h , calc draw.c .

The following functions do not modify border pixels; they do nothing if np is not ok, set not ok on error, and are verbose.

Depending on image dimension and pixels type, use appropriate function.

• NpicDrawRect *

void NpicDrawRect_?c (Npic_image *np,

..., int yP, int xP, ..., int yQ, int xQ, Npic_c val1);

void NpicDrawRect_?l (Npic_image *np,

..., int yP, int xP, ..., int yQ, int xQ, Npic_l val1);

void NpicDrawRect_?d (Npic_image *np,

..., int yP, int xP, ..., int yQ, int xQ, Npic_d val1);

void NpicDrawRect_?q (Npic_image *np,

..., int yP, int xP, ..., int yQ, int xQ, int a1, int b1, int c1, int d1);

Draw a rectangle bounded by P and Q, with pixel value val1. P and Q can be outside image. Replace ? by dimension: 2, 3, 4, 5 or 6.

• NpicDrawEllipse *

void NpicDrawEllipse_?c (Npic_image *np, ..., int yP, int xP, ..., int yQ, int xQ, Npic_c val1);

void NpicDrawEllipse_?l (Npic_image *np, ..., int yP, int xP, ..., int yQ, int xQ, Npic_l val1);

void NpicDrawEllipse_?d (Npic_image *np, ..., int yP, int xP, ..., int yQ, int xQ, Npic_d val1);

void NpicDrawEllipse_?q (Npic_image *np, ..., int yP, int xP, ..., int yQ, int xQ, int a1, int b1, int c1, int d1);

Draw an ellipse bounded by P and Q, with pixel value val1. P and Q can be outside image. Replace ? by dimension: 2, 3, 4, 5 or 6.

1.5.6 Drawing lines

Sources: calc bresenham.h , calc bresenham.c .

The following functions do not modify border pixels; they do nothing ifnp is not ok, set not ok on error, and are verbose.

Depending on image dimension and pixels type, use appropriate function.

• NpicDrawLine *

void NpicDrawLine_?c (Npic_image *np,

..., int yP, int xP, ..., int yQ, int xQ, Npic_c cP, Npic_c cQ);

void NpicDrawLine_?l (Npic_image *np,

..., int yP, int xP, ..., int yQ, int xQ, Npic_l cP, Npic_l cQ);

void NpicDrawLine_?d (Npic_image *np,

..., int yP, int xP, ..., int yQ, int xQ, Npic_d cP, Npic_d cQ);

void NpicDrawLine_?q (Npic_image *np,

..., int yP, int xP, ..., int yQ, int xQ,

1.6. DISTANCE TRANSFORMATIONS 33

Dans le document The Npic library Reference Manual (Page 28-33)

Documents relatifs