📄 img_sobel.h
字号:
/* short cols, short rows // Image dimensions // */
/* ) */
/* { */
/* // ------------------------------------------------ // */
/* // Intermediate values. // */
/* // ------------------------------------------------ // */
/* int H; // Horizontal mask result // */
/* int V; // Vertical mask result // */
/* int O; // Sum of horizontal and vertical masks // */
/* int i; // Input pixel offset // */
/* int o; // Output pixel offset. // */
/* int xy; // Loop counter. // */
/* */
/* // ------------------------------------------------ // */
/* // Input values. // */
/* // ------------------------------------------------ // */
/* int i00, i01, i02; */
/* int i10, i12; */
/* int i20, i21, i22; */
/* */
/* // ------------------------------------------------ // */
/* // Step through the entire image. We step // */
/* // through 'rows - 2' rows in the output image, // */
/* // since those are the only rows that are fully // */
/* // defined for our filter. // */
/* // ------------------------------------------------ // */
/* for (xy = 0, i = cols + 1, o = 1; */
/* xy < cols*(rows-2) - 2; */
/* xy++, i++, o++) */
/* { */
/* */
/* // -------------------------------------------- // */
/* // Read necessary data to process an input // */
/* // pixel. The following instructions are // */
/* // written to reflect the position of the // */
/* // input pixels in reference to the pixel // */
/* // being processed, which would correspond // */
/* // to the blank space left in the middle. // */
/* // -------------------------------------------- // */
/* i00=in[i-cols-1]; i01=in[i-cols]; i02=in[i-cols+1]; */
/* i10=in[i -1]; i12=in[i +1]; */
/* i20=in[i+cols-1]; i21=in[i+cols]; i22=in[i+cols+1]; */
/* */
/* // -------------------------------------------- // */
/* // Apply the horizontal mask. // */
/* // -------------------------------------------- // */
/* H = -i00 - 2*i01 - i02 + i20 + 2*i21 + i22; */
/* */
/* // -------------------------------------------- // */
/* // Apply the vertical mask. // */
/* // -------------------------------------------- // */
/* V = -i00 + i02 - 2*i10 + 2*i12 - i20 + i22; */
/* */
/* O = abs(H) + abs(V); */
/* */
/* // -------------------------------------------- // */
/* // If the result is over 255 (largest valid // */
/* // pixel value), saturate (clamp) to 255. // */
/* // -------------------------------------------- // */
/* if (O > 255) O = 255; */
/* */
/* // -------------------------------------------- // */
/* // Store the result. // */
/* // -------------------------------------------- // */
/* out[o] = O; */
/* } */
/* } */
/* */
/* TECHNIQUES */
/* Eight output pixels are computed per iteration using loop unrolling */
/* and packed operations. */
/* The prolog is only partially collapsed because use of predicate is */
/* not possible since there is no free instruction slot avaible in */
/* the kernel. */
/* The last stage of the epilog is kept to accommodate for the */
/* exception of storing only 6 outputs in the last iteration. */
/* */
/* ASSUMPTIONS */
/* At least eight output pixels must be processed. */
/* The input image width must be even (eg. 'cols' must be even). */
/* */
/* MEMORY NOTE */
/* No bank conflicts occur ever. */
/* */
/* NOTES */
/* This is a LITTLE ENDIAN implementation. */
/* The image arrays do not need to be aligned. */
/* */
/* The values of the left-most and right-most pixels on each line */
/* of the output are not well-defined. */
/* */
/* CYCLES */
/* cycles = 11 * cols * (rows-2)/8 + 23 */
/* For cols = 128 and rows = 128, cycles = 22,199. */
/* */
/* CODESIZE */
/* 688 bytes. */
/* ------------------------------------------------------------------------ */
/* Copyright (c) 2003 Texas Instruments, Incorporated. */
/* All Rights Reserved. */
/* ======================================================================== */
#ifndef IMG_SOBEL_H_
#define IMG_SOBEL_H_ 1
void IMG_sobel
(
const unsigned char *in_data, /* Input image data */
unsigned char *out_data, /* Output image data */
short cols, short rows /* Image dimensions */
);
#endif
/* ======================================================================== */
/* End of file: img_sobel.h */
/* ------------------------------------------------------------------------ */
/* Copyright (c) 2003 Texas Instruments, Incorporated. */
/* All Rights Reserved. */
/* ======================================================================== */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -