1 | /***************************************************************************
|
---|
2 | *
|
---|
3 | * Copyright 2000 by David Demirdjian. All rights reserved.
|
---|
4 | *
|
---|
5 | * Developed by David Demirdjian
|
---|
6 | *
|
---|
7 | * Permission to use, copy, or modify this software and its documentation
|
---|
8 | * for educational and research purposes only and without fee is hereby
|
---|
9 | * granted, provided that this copyright notice and the original authors's
|
---|
10 | * names appear on all copies and supporting documentation. If individual
|
---|
11 | * files are separated from this distribution directory structure, this
|
---|
12 | * copyright notice must be included. For any other uses of this software,
|
---|
13 | * in original or modified form, including but not limited to distribution
|
---|
14 | * in whole or in part, specific prior permission must be obtained from
|
---|
15 | * MIT. These programs shall not be used, rewritten, or adapted as the
|
---|
16 | * basis of a commercial software or hardware product without first
|
---|
17 | * obtaining appropriate licenses from David Demirdjian. The author makes
|
---|
18 | * no representations about the suitability of this software for any purpose.
|
---|
19 | * It is provided "as is" without express or implied warranty.
|
---|
20 | *
|
---|
21 | **************************************************************************/
|
---|
22 | #ifndef _PROCESSING_MMX_H
|
---|
23 | #define _PROCESSING_MMX_H
|
---|
24 |
|
---|
25 | typedef unsigned char uchar;
|
---|
26 | typedef unsigned short ushort;
|
---|
27 |
|
---|
28 | // translate image of 'tx' pixels to the right
|
---|
29 | // (or left if tx<0)
|
---|
30 | inline void translateImage(int tx, uchar* data1, int siz);
|
---|
31 |
|
---|
32 | // normalize intensities in images
|
---|
33 | inline void normalizeImages(uchar* data1, uchar* data2, uchar* data3, int siz);
|
---|
34 | inline void normalizeImages(uchar* data1, uchar* data, int siz);
|
---|
35 | inline void normalizeImages(const uchar* data1, const uchar* data2, const uchar* data3,
|
---|
36 | uchar* out1, uchar* out2, uchar* out3, int siz);
|
---|
37 | inline void normalizeImages(const uchar* data1, const uchar* data2,
|
---|
38 | uchar* out1, uchar* out2, int siz);
|
---|
39 |
|
---|
40 | // shrink images by a factor 'fact'. eg if fact = 2, out will be twice as small as src
|
---|
41 | inline void shrinkImages(uchar* dst, const uchar* src, int width, int height, int fact);
|
---|
42 |
|
---|
43 |
|
---|
44 | // ImgSub2: D = saturation0(|S1 - S2| + |S1 - S3|)
|
---|
45 | inline int ImgSubandAdd(const uchar *Src1, const uchar *Src2,
|
---|
46 | const uchar *Src3, uchar *Dest, int l);
|
---|
47 | // int ImgSubandAdd_sse2(const uchar *Src1, const uchar *Src2, const uchar *Src3, uchar *Dest, int l);
|
---|
48 | inline int ImgSubandAdd(const uchar *Src1, const uchar *Src2,
|
---|
49 | uchar *Dest, int l);
|
---|
50 |
|
---|
51 | inline int ImgSubandAdd2(const uchar *Src1, const uchar *Src2,
|
---|
52 | const uchar *Src3, uchar* Dest1, int l, int imageSize, int width);
|
---|
53 | inline int ImgSubandAdd2_Vert(const uchar *Src1, const uchar *Src2,
|
---|
54 | uchar* Dest1,
|
---|
55 | int l, int imageSize, int width);
|
---|
56 | inline int ImgSubandAdd_Horiz(const uchar *Src1, const uchar *Src3, uchar* Dest1,
|
---|
57 | int l, int imageSize, int width);
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 | // ---------------------
|
---|
62 | // init BestCorrelation and SecondCOrrelation with CurrentCorrelation
|
---|
63 | // init Disparity with disparityInit
|
---|
64 | inline int initMinimumCorrelation(const uchar *CurrentCorrelation, uchar disparityInit, uchar *Disparity,
|
---|
65 | uchar *BestCorrelation, uchar *SecondCorrelation, int bytecount);
|
---|
66 | // ----------------------
|
---|
67 | // FULL IMAGE, BEST ONLY : Keith's code
|
---|
68 | inline int findMinimumCorrelation_mmx(const uchar *CurrentCorrelation, uchar CurrentDisparity, uchar *Disparity,
|
---|
69 | uchar *BestCorrelation, int bytecount) ;
|
---|
70 | // ----------------------
|
---|
71 | // FULL IMAGE, BEST+SECOND : Keith's code
|
---|
72 | inline int findMinimumCorrelation_mmx( const uchar *CurrentCorrelation, uchar CurrentDisparity, uchar *Disparity,
|
---|
73 | uchar *BestCorrelation, uchar *SecondCorrelation, int bytecount);
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 | // ------------------------ image filters -------------------------------
|
---|
78 | inline void sum_5x5_mmx(uchar* im, ushort* im_out, int dataSize, int width, ushort* buff);
|
---|
79 | inline void sum_5x5_mmx(uchar* im, uchar* im_out, int dataSize, int width, ushort* buff);
|
---|
80 |
|
---|
81 | // ------- row filters -------
|
---|
82 | template<class T> void sum_Row_5(T* im, ushort* im_out, int rowSize);
|
---|
83 | inline void sum_Row_mmx(uchar* im, ushort* im_out, int rowSize, int maskSize);
|
---|
84 | inline void sum_Row_mmx(ushort* im, ushort* im_out, int rowSize, int maskSize) ;
|
---|
85 | inline void sum_Row_5_mmx(uchar* im, ushort* im_out, int rowSize);
|
---|
86 | inline void sum_Row_5_mmx(ushort* im, ushort* im_out, int rowSize);
|
---|
87 |
|
---|
88 | // ------- cols filters -------
|
---|
89 | inline void avg_Col(ushort* im, uchar* im_out, int dataSize, int width, int sizeMask);
|
---|
90 |
|
---|
91 | inline void avg_Col_mmx(ushort* im, uchar* im_out, int dataSize, int width, int sizeMask);
|
---|
92 | inline void avg_Col_sse2(ushort* im, uchar* im_out, int dataSize, int width, int sizeMask);
|
---|
93 | inline void avg_Col_5(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
94 | inline void avg_Col_7(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
95 | inline void avg_Col_9(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
96 | inline void avg_Col_11(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
97 | inline void avg_Col_13(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
98 | inline void avg_Col_15(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
99 | inline void avg_Col_17(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
100 |
|
---|
101 | inline void add_Col_5_wb(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
102 | inline void add_Col_5_ww(ushort* im, ushort* im_out, int dataSize, int width);
|
---|
103 |
|
---|
104 | // ------- cols filters -------
|
---|
105 | inline void avg_Col_5_sse2(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
106 | inline void avg_Col_7_sse2(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
107 | inline void avg_Col_9_sse2(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
108 | inline void avg_Col_11_sse2(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
109 | inline void avg_Col_13_sse2(ushort* im, uchar* im_out, int dataSize, int width);
|
---|
110 |
|
---|
111 |
|
---|
112 | // return the average pixel value
|
---|
113 | inline float pixelMean(const uchar* im, int imageSize);
|
---|
114 |
|
---|
115 | // check that the diff. between best and second disp. scores in great enough
|
---|
116 | inline void compareBestAndSecond(uchar* bestScores, uchar* secondScores, char thresh,
|
---|
117 | uchar valForReplacement,
|
---|
118 | uchar* disp, int dataSize);
|
---|
119 |
|
---|
120 | // image copy
|
---|
121 | // windowWidth must be multiple of 8
|
---|
122 | inline void cropImage(const uchar* imSrc, int width, int height,
|
---|
123 | uchar* imDest, int x0, int y0, int windowWidth, int windowHeight);
|
---|
124 |
|
---|
125 |
|
---|
126 |
|
---|
127 | // apply mask: if mask[]==undefined_val im[]->im[]
|
---|
128 | // otherwise im[]->mask[]
|
---|
129 | inline void overrideImage(uchar* im, const uchar* mask, uchar undefined_val, int imageSize);
|
---|
130 | inline void overrideImageMMX(uchar* im, const uchar* mask, uchar undefined_val, int imageSize);
|
---|
131 | inline void copyMMX(void* imDest, const void* imSrc, int dataSize);
|
---|
132 | inline void copySSE(void* imDest, const void* imSrc, int dataSize);
|
---|
133 | inline void setMMX(float* imDest, const float value, int dataSize);
|
---|
134 | inline void setMMX(char* imDest, const char value, int dataSize);
|
---|
135 |
|
---|
136 | // multiply im. by a constant 'fact'
|
---|
137 | inline void multiply(uchar* im, float fact, int imageSize);
|
---|
138 | inline void multiply(const uchar* imSrc, uchar* imDest, float fact, int imageSize);
|
---|
139 | inline void divide(ushort* im, uchar* div, uchar* result, int imageSize);
|
---|
140 | inline void binarize(uchar* im, uchar* im_out, uchar undefined_val, int dataSize);
|
---|
141 | inline void set_undefined_to_zero(uchar* im, uchar* im_out, uchar undefined_val, int dataSize);
|
---|
142 | inline void set_zero_to_undefined(uchar* im, uchar* im_out, uchar undefined_val, int dataSize);
|
---|
143 |
|
---|
144 | // check depth validity
|
---|
145 | void checkDisparityValidity(uchar* disp, uchar* buff, int buffStep,
|
---|
146 | uchar* bestScore, uchar tol,
|
---|
147 | uchar undefined_val, uchar nbDepth,
|
---|
148 | int imageSize);
|
---|
149 | void checkDisparityValidityAndSearchAround(uchar* disp, uchar* buff, int buffStep,
|
---|
150 | uchar* bestScore, uchar tol,
|
---|
151 | uchar undefined_val, uchar nbDepth,
|
---|
152 | int imageSize);
|
---|
153 | // 3D reconst
|
---|
154 | //void createIdxValidPixelsList(const uchar* depth_image, int* idx_valid_pixels, int& nbPoints, int siz, int UNDEFINED_DEPTH);
|
---|
155 |
|
---|
156 | #include "processingMMX.inl"
|
---|
157 | #include "processingSSE2.inl"
|
---|
158 |
|
---|
159 | #endif
|
---|