ERIS Pipeline Reference Manual 1.9.2
eris_utils_image.c
1
2/* *
3 * This file is part of the ESO X-shooter Pipeline *
4 * Copyright (C) 2006 European Southern Observatory *
5 * *
6 * This library is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
19 * */
20
21/*
22 * $Author: amodigli $
23 * $Date: 2013-03-13 12:35:04 $
24 * $Revision: 1.87 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#include <eris_utils_image.h>
35cpl_image*
36eris_scharr_x(cpl_image* in) {
37
38 cpl_image* scharr_x = NULL;
39 double* pscharr_x = NULL;
40 double* pin = NULL;
41
42
43 scharr_x = cpl_image_duplicate(in);
44 pscharr_x = cpl_image_get_data_double(scharr_x);
45 pin = cpl_image_get_data_double(in);
46 cpl_size sx = cpl_image_get_size_x(in);
47 cpl_size sy = cpl_image_get_size_y(in);
48
49 for(cpl_size i = 1; i < sx - 1;i++) {
50 for(cpl_size j = 1; j < sy - 1;j++) {
51 pscharr_x[i + j*sx] = 3 * pin[i-1 + (j+1)*sx] - 3 * pin[i + 1+ (j+1)*sx]+
52 10 * pin[i - 1 + j*sx] - 10 * pin[i + 1 + j*sx]+
53 3 * pin[i - 1 + (j-1) * sx] - 3 * pin[i + 1 + (j-1) * sx];
54 }
55 }
56
57
58 return scharr_x;
59
60}
61
62
63
70cpl_image*
71eris_scharr_y(cpl_image* in) {
72
73 cpl_image* scharr_y=NULL;
74 double* pscharr_y=NULL;
75 double* pin=NULL;
76
77 scharr_y = cpl_image_duplicate(in);
78 pscharr_y = cpl_image_get_data_double(scharr_y) ;
79 pin = cpl_image_get_data_double(in);
80 cpl_size sx = cpl_image_get_size_x(in) ;
81 cpl_size sy = cpl_image_get_size_y(in);
82
83 for(cpl_size i = 1;i < sx-1;i++) {
84 for(cpl_size j = 1;j < sy-1;j++) {
85 pscharr_y[i+j*sx]=3*pin[i-1+(j+1)*sx]+10*pin[i+(j+1)*sx]+3*pin[i+1+(j+1)*sx]+
86 -3*pin[i-1+(j-1)*sx]-10*pin[i+(j-1)*sx]-3*pin[i+1+(j-1)*sx];
87 }
88 }
89
90 return scharr_y;
91
92}
93
94
102cpl_image*
103eris_sobel_lx(cpl_image* in) {
104
105 cpl_image* lx = NULL;
106 double* plx = NULL;
107 double* pin = NULL;
108
109 lx = cpl_image_duplicate(in);
110 plx = cpl_image_get_data_double(lx);
111 pin = cpl_image_get_data_double(in);
112 cpl_size sx = cpl_image_get_size_x(in);
113 cpl_size sy = cpl_image_get_size_y(in);
114
115 for(cpl_size i=1;i<sx-1;i++) {
116 for(cpl_size j=1;j<sy-1;j++) {
117 plx[i+j*sx]=pin[i-1+(j+1)*sx]-pin[i+1+(j+1)*sx]+
118 2*pin[i-1+j*sx]-2*pin[i+1+j*sx]+
119 pin[i-1+(j-1)*sx]-pin[i+1+(j-1)*sx];
120 }
121 }
122
123 return lx;
124
125}
126
127
128
136cpl_image*
137eris_sobel_ly(cpl_image* in) {
138
139
140
141 cpl_image* ly=NULL;
142 double* ply=NULL;
143 double* pin=NULL;
144
145
146
147 ly = cpl_image_duplicate(in);
148 ply = cpl_image_get_data_double(ly);
149 pin = cpl_image_get_data_double(in);
150 cpl_size sx = cpl_image_get_size_x(in);
151 cpl_size sy = cpl_image_get_size_y(in);
152
153 for(cpl_size i=1;i<sx-1;i++) {
154 for(cpl_size j=1;j<sy-1;j++) {
155 ply[i+j*sx]=pin[i-1+(j+1)*sx]+2*pin[i+(j+1)*sx]+pin[i+1+(j+1)*sx]+
156 -pin[i-1+(j-1)*sx]-2*pin[i+(j-1)*sx]-pin[i+1+(j-1)*sx];
157 }
158 }
159
160 return ly;
161
162}