MCPcopy Create free account
hub / github.com/alicevision/AliceVision / ImageRemoveDistortion

Function ImageRemoveDistortion

src/software/utils/main_exportImages.cpp:151–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149
150template<typename T>
151void ImageRemoveDistortion(const image::Image<T>& imageIn,
152 const camera::IntrinsicBase & intrinsicSource,
153 const camera::IntrinsicBase & intrinsicOutput,
154 image::Image<T>& image_ud,
155 T fillcolor,
156 const oiio::ROI& roi = oiio::ROI())
157{
158 int widthRoi = intrinsicOutput.w();
159 int heightRoi = intrinsicOutput.h();
160 int xOffset = 0;
161 int yOffset = 0;
162 if (roi.defined())
163 {
164 widthRoi = roi.width();
165 heightRoi = roi.height();
166 xOffset = roi.xbegin;
167 yOffset = roi.ybegin;
168 }
169
170 image_ud.resize(widthRoi, heightRoi, true, fillcolor);
171 const image::Sampler2d<image::SamplerLinear> sampler;
172
173#pragma omp parallel for
174 for (int y = 0; y < heightRoi; ++y)
175 {
176 for (int x = 0; x < widthRoi; ++x)
177 {
178 const Vec2 undisto_pix(x + xOffset, y + yOffset);
179
180 // compute coordinates with distortion
181 const Vec2 disto_pix = intrinsicSource.cam2ima(intrinsicSource.addDistortion(
182 intrinsicOutput.ima2cam(undisto_pix)));
183
184 // pick pixel if it is in the image domain
185 if (imageIn.contains(disto_pix(1), disto_pix(0)))
186 {
187 image_ud(y, x) = sampler(imageIn, disto_pix(1), disto_pix(0));
188 }
189 }
190 }
191}
192
193/**
194 * @Brief process an image such that they appear captured by a new virtual intrinsic

Callers 1

processImageFunction · 0.85

Calls 10

ROIClass · 0.85
wMethod · 0.80
hMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
resizeMethod · 0.45
cam2imaMethod · 0.45
addDistortionMethod · 0.45
ima2camMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected