29 return (
int)((double)rand()*127/(double)RAND_MAX);
33 void drawLine(vigra::DRGBImage& img,
int x0,
int y0,
int x1,
int y1, vigra::RGBValue<int>& color)
35 bool steep = (abs(y1 - y0) > abs(x1 - x0));
49 int deltay = abs(y1 - y0);
50 int error = -(deltax + 1) / 2;
63 for(
int x=x0; x<=x1; ++x)
87 double aDoubleFactor = 1.0;
94 std::cout <<
"writing file outcomp.png ..." << std::endl;
97 vigra::ImageImportInfo info1(i1.c_str());
98 vigra::ImageImportInfo info2(i2.c_str());
100 vigra::DRGBImage out1(info1.width() * 2, info1.height());
102 if ((info1.width() != info2.width()) || (info1.height() != info2.height()))
104 std::cout <<
"images of different size, skip write of test img" << std::endl;
108 if(info1.isGrayscale())
110 vigra::DImage aImageGrey(info1.width(), info1.height());
111 importImage(info1,
destImage(aImageGrey));
115 aImageGrey.lowerRight(),
116 vigra::DImage::Accessor(),
118 vigra::DImage::Accessor());
123 vigra::DRGBImage aImageRGB(info1.width(), info1.height());
124 if(info1.numExtraBands() == 1)
126 vigra::BImage aAlpha(info1.size());
129 else if (info1.numExtraBands() == 0)
131 vigra::importImage(info1,
destImage(aImageRGB));
136 aImageRGB.lowerRight(),
137 vigra::RGBToGrayAccessor<vigra::RGBValue<double> >(),
139 vigra::DImage::Accessor());
142 if(info2.isGrayscale())
144 vigra::DImage aImageGrey(info2.width(), info2.height());
145 importImage(info2,
destImage(aImageGrey));
149 aImageGrey.lowerRight(),
150 vigra::DImage::Accessor(),
151 out1.upperLeft() + vigra::Diff2D(info1.width(), 0),
152 vigra::DImage::Accessor());
157 vigra::DRGBImage aImageRGB(info2.width(), info2.height());
158 if(info2.numExtraBands() == 1)
160 vigra::BImage aAlpha(info2.size());
163 else if (info2.numExtraBands() == 0)
165 vigra::importImage(info2,
destImage(aImageRGB));
170 aImageRGB.lowerRight(),
171 vigra::RGBToGrayAccessor<vigra::RGBValue<double> >(),
172 out1.upperLeft() + vigra::Diff2D(info1.width(), 0),
173 vigra::DImage::Accessor());
176 for (
size_t i = 0; i < iOK.size(); ++i)
180 drawLine(out1, aDoubleFactor * aV->_img1_x,
181 aDoubleFactor * aV->_img1_y,
182 aDoubleFactor * aV->_img2_x + info1.width(),
183 aDoubleFactor * aV->_img2_y, color);
187 iRansac.
transform(aV->_img1_x, aV->_img1_y, x1p, y1p);
200 if (x1p > info1.width())
204 if (y1p > info1.height())
206 y1p=info1.height()-1;
209 vigra::RGBValue<int> color2(0, 255 , 255);
210 drawLine(out1, aDoubleFactor * aV->_img2_x + info1.width(),
211 aDoubleFactor * aV->_img2_y,
212 aDoubleFactor * x1p + info1.width(),
213 aDoubleFactor * y1p, color2);
217 for(
size_t i=0; i<iNOK.size(); ++i)
221 drawLine(out1, aDoubleFactor * aV->_img1_x,
222 aDoubleFactor * aV->_img1_y,
223 aDoubleFactor * aV->_img2_x + info1.width(),
224 aDoubleFactor * aV->_img2_y, color);
228 iRansac.
transform(aV->_img1_x, aV->_img1_y, x1p, y1p);
240 if (x1p > info1.width())
244 if (y1p > info1.height())
246 y1p=info1.height()-1;
249 vigra::RGBValue<int> color2(0, 255 , 255);
250 drawLine(out1, aDoubleFactor * aV->_img2_x + info1.width(),
251 aDoubleFactor * aV->_img2_y,
252 aDoubleFactor * x1p + info1.width(),
253 aDoubleFactor * y1p, color2);
257 exportImage(
srcImageRange(out1), vigra::ImageExportInfo(
"outcomp.png"));
static void swap(T &x, T &y)
std::vector< PointMatchPtr > PointMatchVector_t
void transform(double iX, double iY, double &oX, double &oY)
vigra::pair< typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::ImageAccessor > destImage(ROIImage< Image, Alpha > &img)
static void drawRansacMatches(std::string &i1, std::string &i2, lfeat::PointMatchVector_t &iOK, lfeat::PointMatchVector_t &iNOK, lfeat::Ransac &iRansac, bool iHalf)
vigra::triple< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImageRange(const ROIImage< Image, Mask > &img)
helper function for ROIImages
void copyImage(SrcImageIterator src_upperleft, SrcImageIterator src_lowerright, SrcAccessor src_acc, DestImageIterator dest_upperleft, DestAccessor dest_acc)
void drawLine(vigra::DRGBImage &img, int x0, int y0, int x1, int y1, vigra::RGBValue< int > &color)
std::shared_ptr< PointMatch > PointMatchPtr