-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dsp/p_conv_f32: Remove an extra element in the result, Fix a problem in involving uninitialize memory addresses in computation. image/p_conv2d_f32: Returns incorrect values as it doesn't flip the kernel in vertical and horizontal directions, Support for rectangular kernels. image/p_median3x3.c: For 3x3 median filter, I replaced it with hardwired median search described here: http:users.utcluj.ro/~baruch/resources/Image/xl23_16.pdf Extra information Signed-off-by: Hamid Ebadi <[email protected]> Counter example for p_conv_f32 Response from FreeMat: --> x = [1, 2, 3, 4]; --> h = [5,6,7]; --> r = conv(x, h) r = 5 16 34 52 45 28 Response from pal: float x[4] = {1,2,3,4}; float h[3] = {5,6,7} ; float r[10] = {100,100,100,100,100,100, 100, 100,100, 100}; p_conv_f32( x, h , r ,4 ,3); printf ("%f, %f, %f, %f, %f, %f, %f, %f", r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7]); 100.000000, 105.000000, 116.000000, 134.000000, 152.000000, 145.000000, 128.000000, 100.000000 Counter example for p_conv2d_f32 Response from FreeMat: --> A= [17 24 1 8 15; 23 5 7 14 16; 4 6 13 20 22;10 12 19 21 3; 11 18 25 2 9] --> B=[1 3 1; 0 5 0; 2 1 2] --> E=[0 0 0; 0 1 0; 0 0 0] --> C2 = conv2(A,E,'valid') <-- works correctly since kernel is symmetric --> C1 = conv2(A,B,'valid') <-- Doesn't work correctly 120, 165, 205, 160, 200, 245, 190, 255, 235, Response from pal: 155.0, 135.0, 200.0, 145.0, 190.0, 230.0, 185.0, 225.0, 270.0, int main(int argc, char *argv[]) { int i, j; float src[5*5] = {17,24,1,8,15, 23,5,7,14,16, 4,6,13,20,22, 10,12,19,21,3, 11,18,25,2,9 }; float kernel[3*3] = { 1,3,1, 0,5,0, 2,1,2 }; float dest[3*3]; p_conv2d_f32(src, kernel, dest, 5, 5, 3); for (i = 0; i < W; i++) { for (j = 0; j < W; j++) { printf("%.1f, ", src[i*W+j]); } printf("\n"); } printf("\n"); for (i = 0; i < W2; i++) { for (j = 0; j < W2; j++) { printf("%.1f, ", dest[i*W2+j]); } printf("\n"); } }
- Loading branch information
Showing
5 changed files
with
63 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dca21ba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In p_conv.c, why is it necessary to declare rx and xc in lines 23 and 24?
23 const float *xc = x;
24 float *rx = r;
I tried with neither xc nor rx and it works.
dca21ba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I re-factored the code and removed xc. However I cannot see why rx is unnecessary ?
https://github.com/ebadi/pal/blob/6f5b040f409f9f71bc4b0088d56965d703626492/src/dsp/p_conv.c