当前位置: 首页>>代码示例>>C++>>正文


C++ ImageReader类代码示例

本文整理汇总了C++中ImageReader的典型用法代码示例。如果您正苦于以下问题:C++ ImageReader类的具体用法?C++ ImageReader怎么用?C++ ImageReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ImageReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: trainTree

void trainTree(string treeFile, string trainDir) {

	SerializeHelper sHelp = SerializeHelper();
	
	ImageReader imReader = ImageReader();
	
	vector<Mat> depthImages = imReader.readDepthImages(trainDir);
	vector<Mat> classifiedImages = imReader.readClassifiedImages(trainDir);

	int times = clock();

	// 7 classes, 15 deep, 200 features, 50 thresholds, 0.02 subsampling, 1 minnuminnode, 10 background penalty, feature range, threshold range
	Forest forest = Forest(6, 15, 500, 100, 0.05, 10, 0, pair<double, double>(150, 150), pair<double, double>(-255,255));

	// 500 image per tree. Three made at once.
	forest.makeTrees(depthImages, classifiedImages, 150, 3);

	int timed = clock();

	cout << "Making trees took "<< (timed-times) <<" ticks.\n"<< endl;

	//Forest forest = sHelp.loadForest("MediumTree100F1000.txt");
	sHelp.serializeForest(forest, treeFile);
	string graphvix = forest.getTrees().at(0)->graphvizPrint(-1, NULL);
	
	

}
开发者ID:TLadd,项目名称:SeniorDesign,代码行数:28,代码来源:RandomFor.cpp

示例2: QColor

std::vector<float> ShapeEstimation::computePixelLuminance(ImageReader imageIn, ImageReader mask, float &sigma){
    int rows = imageIn.getImageHeight();
    int cols = imageIn.getImageWidth();
    std::vector<float> pixelLuminances;

    int pixelsInObject = 0;
    float objectLuminanceSum = 0.0f;
    for(int row = 0; row < rows; row++){
        for(int col = 0; col < cols; col++){
            QColor imageColor = QColor(imageIn.pixelAt(row, col));
            QColor maskColor = QColor(mask.pixelAt(row, col));
            if((maskColor.red() > 150)){
                pixelsInObject += 1;
                float luminance =  0.213f * float(imageColor.red()) + 0.715f * float(imageColor.green()) + 0.072f * float(imageColor.blue());
                if(luminance == 0.0f){
                    luminance = 0.0001f;
                }
                pixelLuminances.push_back(luminance/ 255.0f);
                objectLuminanceSum += log(luminance / 255.0f);
            } else {
                if(DEPTHMAPBACKGROUND){
                     pixelLuminances.push_back(1.0f);
                } else {
                     pixelLuminances.push_back(0.0f);
                }
            }
        }
    }
    sigma = exp(objectLuminanceSum / float(pixelsInObject));
    return pixelLuminances;
}
开发者ID:nlindsay19,项目名称:ReallyRealFinal,代码行数:31,代码来源:shapeestimation.cpp

示例3: calculateTexture

void Retexture::calculateTexture(std::vector<Vector3f> T, std::vector<Vector3f> background, std::vector<Vector3f> image, std::vector<float> deltaX, std::vector<float> deltaY, std::vector<Vector3f> &result, ImageReader mask)
{
    int width = mask.getImageWidth();
    std::cout << width << std::endl;
    float cmaxAverage = 0.0f;

    for (int i = 0; i < T.size(); i++) {
        int x = i % width;
        int y = i / width;

        if(QColor(mask.pixelAt(y,x)).red() < 150) {
            // Black part of the mask, don't do anything
            result.push_back(background[i]);
            continue;
        }

        int t_x = fmod(float(x) + m_s*deltaX[i], width);
        int t_y = fmod(float(y) + m_s*deltaY[i], mask.getImageHeight());
        Vector3f t_value = T[t_y*width + t_x];
        Vector3f resultValue = (1.f - m_f) * t_value + m_f * image[i];

        float resultAverage = (resultValue[0] + resultValue[1] + resultValue[2])/3.0f;
        if(cmaxAverage < resultAverage){
            cmaxAverage = resultAverage;
        }
        result.push_back(resultValue);
    }
}
开发者ID:nlindsay19,项目名称:ReallyRealFinal,代码行数:28,代码来源:retexture.cpp

示例4: getImageFileByExtension

void LoadTextureAMT::processCPU_Texture2D(const RJNode& header)
{
    if(ji::hasChild(header, "images"))
    {
        const RJNode& images = ji::getChild(header, "images");
        if(images.is_array() && images.size() > 0)
        {
            m_target = GL_TEXTURE_2D;

            const RJNode& img = images.at(0);
            std::string imageFilePath = ji::read(img, "filePath", DV_STRING);

            // Fail loading if given extension is not supported or file is invalid.
            ImageReader* reader = getImageFileByExtension(imageFilePath);
            if(!reader || !reader->isValid())
            {
                utils::deleteAndNull(reader);
                return;
            }

            m_imageReaders[0] = reader;
            m_imageGLFormat = reader->getOpenGLInternalFormat();
        }
    }
}
开发者ID:creepydragon,项目名称:r2,代码行数:25,代码来源:LoadTextureAMT.cpp

示例5: method_prepShowImage

/**
 * prepShowImage - Save normalized image to be viewable for modification
 * 
 * @param	filename	Name of the file to normalize
 */
extern "C" VALUE method_prepShowImage(VALUE self, VALUE rubyfilename, VALUE rubyoutname) {
	std::string strfname( StringValueCStr( rubyfilename ) );
	std::string stroutname( StringValueCStr( rubyoutname) );
	ImageReader imr;
	imr.prepShowImage(strfname, stroutname);
	return self;
}
开发者ID:nikkoschaff,项目名称:gsimgproc,代码行数:12,代码来源:Imgproc.cpp

示例6: main

/**
 * Entry point to the application
 *
 * @param argc Number of program arguments
 * @param argv Array of program arguments
 *
 * @return 0 on success, non-zero on failure
 */
int main(int argc, char* argv[]) {

	if (argc != 3) {
		cout << "Usage: " << argv[0] << " [searchTerm] [numImages]" << endl;
		return -1;
	}

	char search[] = "-s";
	char* searchTerm = argv[1];
	char num[] = "-n";
	char* numImages = argv[2];

	char* flickrFlags[] = { argv[0], search, searchTerm, num, numImages };
	Flickr flickr;
	if (flickr.init(5, flickrFlags) < 0) {
		cout << "Error initializing flickr!" << endl;
		return -1;
	}

	list<string> urlBuf;
	if (flickr.gather_images(urlBuf) < 0) {
		cout << "Error querying Flickr for images!" << endl;
		return -1;
	}

	ImageReader ir;
	TileImage tile;
	for (list<string>::iterator i = urlBuf.begin(); i != urlBuf.end(); i++) {
		string url = *i;
		string fileName = safeFilename(url);
		if (fileExists(fileName)) {
			cout << "Exists: " << fileName << endl;
			continue;
		}

		if (ir.read_tile_image(url, tile) < 0) {
			cout << "Error reading url: " << url << endl;
			continue;
		}

		try {
			Magick::Image image(tile.get_magick());
			image.write(fileName);
		} catch (Magick::Exception ex) {
			cout << "Error saving file: " << fileName << endl;
			continue;
		}

		cout << "Saved: " << fileName << endl;
	}

	return 0;
}
开发者ID:leloulight,项目名称:cs225,代码行数:61,代码来源:imagedownloader.cpp

示例7: ImageReader

// plik BMP sk³ada siê z nag³ówka (header) i kolorów
// w nag³ówku przechowywane s¹ informacje np. o rozmiarze obrazka
// ale nie tylko. Nag³ówek BMP ma sta³y rozmiar i standardow¹ strutkurê
// dziêki temu wiemy, ¿e na danej pozycji nag³ówka mamy zapisany rozmiar obrazka
// wiêcej o pliku BMP tutaj:
// http://www.dragonwins.com/domains/getteched/bmp/bmpfileformat.htm
// http://www.fileformat.info/format/bmp/egff.htm
// https://en.wikipedia.org/wiki/BMP_file_format
void Image::read_image(string filepath)
{
	// jak skorzystaæ z gotowego kodu wczytywania obrazka
	// ta linijka ni¿ej wczytuje obrazek
	ImageReader* imagereader = new ImageReader(filepath);

	// pozosta³e linijki to robi¹ to czego potrzebujemy
	// czyli g³ównie kopiuj¹ nag³ówek i kolory do odpowiednich miejsc
	// w obiekcie klasy Image
	width = imagereader->get_width();
	height = imagereader->get_height();
	headersize = imagereader->get_header_size();
	header = new char[headersize];

	// Skopiowanie nag³ówka (poniewa¿ nie chcemy nadpisywaæ oryginalnego obrazka)
	for ( int i = 0; i < headersize; i++ )
	{
		header[i] = imagereader->get_header_byte(i);
	}

	// Skopiwanie kolorów do obiektu klasy Pixel
	image = new Pixel*[height]; // dynamiczna tablica pikseli
	for ( int i = 0; i < height; i++ )
	{
		image[i] = new Pixel[width]; // dynamiczna tablica pikseli
		for ( int j = 0; j < width; j++ )
		{
			image[i][j].set_red(imagereader->get_data_byte(i,j,ImageReader::RED));
			image[i][j].set_blue(imagereader->get_data_byte(i,j,ImageReader::BLUE));
			image[i][j].set_green(imagereader->get_data_byte(i,j,ImageReader::GREEN));
		}
	}

	delete imagereader;
}
开发者ID:kasianw,项目名称:Gotowe-i-nawet-dzia-a-,代码行数:43,代码来源:image.cpp

示例8: method_readFiles

/**
 * method_readFiles - main in method for Imgproc.  Reads and returns results
 *
 * @param	self	ruby-required module (not included in ruby method call)
 * @param 	rubyfilenames	The ruby-formatted string array of filenames
 *	(including extension and path!!!)
 * @param	rubynumQ	ruby-formatted number of questions on test
 * @param	rubyReadname	ruby bool value to determine if name to be read
 *
*/
extern "C" VALUE method_readFiles(VALUE self, VALUE rubyfilenames,
 VALUE rubynumQ, VALUE rubyReadname) {
	int numQ = NUM2INT( rubynumQ );
	int numFiles = int( RARRAY_LEN( rubyfilenames ) );
	bool readName = RTEST( rubyReadname );

	// c-style array of filenames
	std::vector<std::string> filenames;
	for( long i = 0; i < numFiles; i++ ) {
		VALUE rubyfn = rb_ary_entry(rubyfilenames,i);
		std::string strfname( StringValueCStr( rubyfn ) );
		filenames.push_back( strfname );
	}

	ImageReader imr;
	std::vector< std::vector< std::vector< float > > > results( numFiles );
    // asynchronize image reads
    //ResGroup group;
	//vector<const ResThread::ResultValue*> results;
	vector< vector< float > > res;
	for(  int i = 0; i < numFiles; i++ ) {
        //group.addThread( filenames[i], numQ, readName );
		res =  imr.readImage( filenames[i], numQ, readName );
		results[i] = res;
	}
    //group.join();
    //group.getResults( results );

    assert( numFiles == int(results.size()) );

	VALUE rbStudents = rb_ary_new();
	// Go through each for each student
	for( int i = 0; i < numFiles; i++ ) {
		// Go through each for each student's answers
		VALUE rbStudentAnswers = rb_ary_new();
		int sz = int( results[i].size() );
		for( int k = 0; k < sz; k++ ) {
			int wsize = int( (results[i])[k].size() );
			VALUE rbStudentAnswerComponents = rb_ary_new();
			for( int w = 0; w < wsize; w++ ) {
				VALUE ansDouble = DBL2NUM( 
                    (results[i])[k][w] );
				rb_ary_push( rbStudentAnswerComponents, ansDouble );
			}
			rb_ary_push( rbStudentAnswers, rbStudentAnswerComponents );
		}
		rb_ary_push( rbStudents, rbStudentAnswers );
	}
	return rbStudents;
}
开发者ID:nikkoschaff,项目名称:gsimgproc,代码行数:60,代码来源:Imgproc.cpp

示例9: main

int main(int argc, const char *argv[])
{
    const std::string str = "~/Desktop/brain/brain_001.dcm" ;
    ImageReader reader ;
    reader.SetFileName(str.c_str()) ;
    Image &image = reader.GetImage() ;
    unsigned int ndim = image.GetNumberOfDimensions() ;
    std::cout << ndim << std::endl ;

    if(!reader.Read()) {
        std::cerr << "Error Bitch" << std::endl ;
        return 1 ;
    }
    return 0;
}
开发者ID:alelos,项目名称:SciVis-Project,代码行数:15,代码来源:main.cpp

示例10: image_read

static PyObject *
image_read(PyObject *self,PyObject *args)
{
    PyObject *pyim;
    PyObject *pyFP;
    int file_type;
    if(!PyArg_ParseTuple(args,"OOi",&pyim,&pyFP,&file_type))
    {
	return NULL;
    }

    if(!PyFile_Check(pyFP))
    {
	return NULL;
    }

    image *i = (image *)PyCObject_AsVoidPtr(pyim);

    FILE *fp = PyFile_AsFile(pyFP);

    if(!fp || !i)
    {
	PyErr_SetString(PyExc_ValueError, "Bad arguments");
	return NULL;
    }
    
    ImageReader *reader = ImageReader::create((image_file_t)file_type, fp, i);
    //if(!reader->ok())
    //{
    //	PyErr_SetString(PyExc_IOError, "Couldn't create image reader");
    //	delete reader;
    //	return NULL;
    //}

    if(!reader->read())
    {
	PyErr_SetString(PyExc_IOError, "Couldn't read image contents");
	delete reader;
	return NULL;
    }
    delete reader;

    Py_INCREF(Py_None);
    return Py_None;
}
开发者ID:Bookaa,项目名称:gnofract4d.simplify,代码行数:45,代码来源:fract4dmodule_gmp.cpp

示例11: while

void imageLoader::run(){
	mutex.lock();
	while( image ){
		//Load data
		QString filepath = file;
		auto loading = std::move( image );
		
		mutex.unlock();
		emit image_fetched();
		
		ImageReader reader; //TODO: initialize in constructor?
		reader.read( *loading, filepath );
		emit image_loaded( loading.get() );
		
		mutex.lock();	//Make sure to lock it again, as wee need it at the while loop check
	}
	mutex.unlock(); //Make sure to lock it when the while loop exits
}
开发者ID:spillerrec,项目名称:imgviewer,代码行数:18,代码来源:imageLoader.cpp

示例12: Check

/**
Function responsible to Prepare the ROM and ROFS image SID data

@internalComponent
@released

@param ImgVsExeStatus - Global integrated container which contains image, exes and attribute value status.
*/
void SidChecker::Check(ImgVsExeStatus& aImgVsExeStatus)
{
    ImageReaderPtrList::iterator begin = iImageReaderList.begin();
    ImageReaderPtrList::iterator end = iImageReaderList.end();

    ExeVsIdDataMap::iterator exeBegin;
    ExeVsIdDataMap::iterator exeEnd;
    ExeVsIdDataMap exeVsIdDataMap;
    ImageReader* imageReader = KNull;
    String imageName;
    while(begin != end)
    {
        imageReader = *begin;
        imageName = imageReader->ImageName();
        ExceptionReporter(GATHERINGIDDATA, (char*)KSid.c_str(),(char*)imageName.c_str()).Log();
        imageReader->PrepareExeVsIdMap();

        exeVsIdDataMap = imageReader->GetExeVsIdMap();
        exeBegin = exeVsIdDataMap.begin();
        exeEnd = exeVsIdDataMap.end();
        if((aImgVsExeStatus[imageName].size() == 0)
                || (aImgVsExeStatus[imageName][exeBegin->first].iIdData == KNull))
        {
            while(exeBegin != exeEnd)
            {
                if(!iSidAll)
                {
                    if(ReaderUtil::IsExe(&exeBegin->second->iUid))
                    {
                        iSidVsExeMap.insert(std::make_pair(exeBegin->second->iSid, exeBegin->first));
                    }
                }
                else
                {
                    iSidVsExeMap.insert(std::make_pair(exeBegin->second->iSid, exeBegin->first));
                }
                aImgVsExeStatus[imageName][exeBegin->first].iIdData = exeBegin->second;
                aImgVsExeStatus[imageName][exeBegin->first].iExeName = exeBegin->first;
                ++exeBegin;
            }
        }
        ++begin;
    }
}
开发者ID:fedor4ever,项目名称:linux_build,代码行数:52,代码来源:sidchecker.cpp

示例13: cropMask

void ShapeEstimation::cropMask(ImageReader mask, std::vector<float> &pixelLuminances){
    int rows = mask.getImageHeight();
    int cols = mask.getImageWidth();

    for(int row = 0; row < rows; row++){
        for(int col = 0; col < cols; col++){
           QColor maskColor = QColor(mask.pixelAt(row, col));
           int index = mask.indexAt(row, col);

           if(maskColor.red() > 150){

           } else {
               if(DEPTHMAPBACKGROUND){
                    pixelLuminances[index] = 1.0f;
               } else {
                    pixelLuminances[index] = 0.0f;
               }
           }
        }
    }
}
开发者ID:nlindsay19,项目名称:ReallyRealFinal,代码行数:21,代码来源:shapeestimation.cpp

示例14: runPrediction

void runPrediction(string treeFile, string testDir, bool writeToFile, string outputFileName) {
	SerializeHelper sHelp = SerializeHelper();
	Forest forest = sHelp.loadForest(treeFile);

	string graphvix = forest.getTrees().at(0)->graphvizPrint(-1, NULL);

	ofstream graphvizFile("graphvizForest.txt");
	graphvizFile << graphvix;

	ImageReader imReader = ImageReader();


	vector<Mat> testDepthImages = imReader.readTrainingImages(testDir);
	
	for(int k=0; k < testDepthImages.size(); k++) {
		Mat classified = forest.classifyImage(testDepthImages.at(k));
		std::ostringstream path;

		path << outputFileName << "/" << k+1 << "Y.png";
		
		string windowName = path.str();
		//namedWindow( windowName, WINDOW_AUTOSIZE );

		//Mat cimg = convertToColorForBaby(classified);
		
		if(writeToFile) {
			//imwrite(windowName, cimg);

			imwrite(windowName, classified);
		}
		//imshow(windowName, cimg);
		//imshow(windowName, classified);
		waitKey(30);
	}

}
开发者ID:TLadd,项目名称:SeniorDesign,代码行数:36,代码来源:RandomFor.cpp

示例15: loadImages

void loadImages(void)
{
    ImageReader		myReader;

    //-------------------------------------------------------------
    //	We read the left image, right image, and disparity map
    //-------------------------------------------------------------
    myReader.setSource(const_cast<char*>(leftImagePath.c_str()));
    gMyLeftImage = myReader.getFrame(false);	//	left image

    myReader.setSource(const_cast<char*>(righttImagePath.c_str()));
    gMyRightImage = myReader.getFrame(false);	//	right image

    //	Normally, I should be able to read the disparity map directly into my
    //	DepthMap's raster.  Then I could render the map as a gray-level image
    //	in one subwindow and draw it as a mesh in an other.  However, at this
    //	point, the "readInto" component of the ImageReader class has not been
    //	implemented, so I had to separate the two operations.
    myReader.setSource(const_cast<char*>(disparityImagePath.c_str()));
    gMyDisparity = static_cast<RasterImage_gray*>(myReader.getFrame(false));	//	disparity map

    //	initially we display the right image in the upper-right subwindow
    gUpperRightDisplay = gMyRightImage;
}
开发者ID:Collins-J-URI,项目名称:eigenfaces,代码行数:24,代码来源:main_stereo.cpp


注:本文中的ImageReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。