// draw gaussian like line void runExpr1(StringVector &args) { if (args.size() < 2) { cout << "--expr1 [output-real-image] [bending-height]" << endl; return; } float bendingHeight = atof(args[1].c_str()); int bandWidth = 12; ImageIO<RealImage2> io; RealImage2::Pointer canvas = io.NewImageT(300, 200, 1); for (int x = 25; x < 275; x++) { double xx = (x - 150) * 0.1; double y = 150 - bendingHeight * exp(-xx*xx/100); RealImage2::IndexType realIdx; for (int j = y; j >= y - bandWidth; j--) { realIdx[0] = x; realIdx[1] = j; canvas->SetPixel(realIdx, 1); } } io.WriteImage(args[0], canvas); }
RealImage::Pointer SIFTImagePCAComputer::computePCImage(SIFTImage* image, int k) { ImageIO<RealImage> io; RealImage::Pointer outputImg = io.NewImageT(image->GetBufferedRegion().GetSize()); SIFTFeature* feature = image->GetBufferPointer(); DataReal* output = outputImg->GetBufferPointer(); const uint size = image->GetPixelContainer()->Size(); const uint featureSize = feature[0].GetNumberOfComponents(); for (uint i = 0; i < size; i++) { uchar* data = feature->GetDataPointer(); float sum = 0; for (uint j = 0; j < featureSize; j++) { sum += this->V[j][featureSize - 1 - k] * data[j]; } *output = std::abs(sum); output++; feature++; } return outputImg; }