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


C++ PNM类代码示例

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


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

示例1: PNM

PNM* NoiseBilateral::transform()
{
    int width  = image->width();
    int height = image->height();

    PNM* newImage = new PNM(width, height, image->format());

    sigma_d = getParameter("sigma_d").toInt();
    sigma_r = getParameter("sigma_r").toInt();
    radius = sigma_d;

    if(image->format() == QImage::Format_Indexed8)
    {
       for(int x=0; x<width; x++)
           for(int y=0; y<height; y++)
           {
               int l = calcVal(x, y, LChannel);
               newImage->setPixel(x, y, l);
           }
    }
    else {
       for(int x=0; x<width; x++)
           for(int y=0; y<height; y++)
           {
              int r = calcVal(x, y, RChannel);
              int g = calcVal(x, y, GChannel);
              int b = calcVal(x, y, BChannel);

              QColor newPixel = QColor(r,g,b);
              newImage->setPixel(x, y, newPixel.rgb());
           }
       }

    return newImage;
}
开发者ID:irmina90,项目名称:pto2014_klozie,代码行数:35,代码来源:noise_bilateral.cpp

示例2: getParameter

PNM* MorphologicalOperator::transform()
{  
    int size  = getParameter("size").toInt();
    SE  shape = (MorphologicalOperator::SE) getParameter("shape").toInt();

    PNM* newImage = new PNM(image->width(), image->height(), QImage::Format_RGB32);

    int width = image->width();
    int height = image->height();

    math::matrix<bool> elementStrukturyzujacy = getSE(size, shape);


    for(int x = 0; x < width; x++)
        for(int y = 0; y < height; y++)
        {
            math::matrix<double> windowR = getWindow(x, y, size, RChannel, RepeatEdge);
            math::matrix<double> windowG = getWindow(x, y, size, GChannel, RepeatEdge);
            math::matrix<double> windowB = getWindow(x, y, size, BChannel, RepeatEdge);

            newImage->setPixel(x, y, qRgb(morph(windowR, elementStrukturyzujacy), morph(windowG, elementStrukturyzujacy), morph(windowB, elementStrukturyzujacy)));
        }

    return newImage;
}
开发者ID:Ridez,项目名称:pto_przetwarzanieObrazow,代码行数:25,代码来源:morphological_operator.cpp

示例3: getParameter

PNM* Correction::transform()
{
    float shift  = getParameter("shift").toFloat();
    float factor = getParameter("factor").toFloat();
    float gamma  = getParameter("gamma").toFloat();

    int width  = image->width();
    int height = image->height();

    PNM* newImage = new PNM(width, height, image->format());

	for (int i = 0; i < 256; i++) {
		Correction::LUT[i] = (int)((((float)(pow((double)i, (double)gamma))) * factor) + shift);
		if (Correction::LUT[i] < 0) {
			Correction::LUT[i] = 0;
		}
		else if (Correction::LUT[i] > 255) {
			Correction::LUT[i] = 255;
		}
	}
	if (image->format() == QImage::Format_Indexed8){
		for (int x = 0; x < width; x++){
			for (int y = 0; y < height; y++)
			{
			QRgb pixel = image->pixel(x, y); // Getting the pixel(x,y) value
			int g = qGray(pixel);    // Get the 0-255 value of the G channel
			g = Correction::LUT[g];
			newImage->setPixel(x, y, g);
			}
	}
	}
	else{
		for (int x = 0; x < width; x++)
			for (int y = 0; y < height; y++)
			{
			QRgb pixel = image->pixel(x, y); // Getting the pixel(x,y) value

			int r = qRed(pixel);    // Get the 0-255 value of the R channel
			int g = qGreen(pixel);  // Get the 0-255 value of the G channel
			int b = qBlue(pixel);   // Get the 0-255 value of the B channel
			r = Correction::LUT[r];
			g = Correction::LUT[g];
			b = Correction::LUT[b];
			QColor newPixel = QColor(r, g, b);
			newImage->setPixel(x, y, newPixel.rgb());
			}
	}


    return newImage;
}
开发者ID:GrzKon,项目名称:pto2014_-lazarskiGIMP,代码行数:51,代码来源:correction.cpp

示例4: getParameter

PNM* Correction::transform()
{
    float shift  = getParameter("shift").toFloat();
    float factor = getParameter("factor").toFloat();
    float gamma  = getParameter("gamma").toFloat();

    int width  = image->width();
    int height = image->height();

    PNM* newImage = new PNM(width, height, image->format());

    // Inicjalizacja tablicy
    for(int i = 0; i<= PIXEL_VAL_MAX; i++) {
        LUT[i] = i;
    }
    // Tablicowanie
    for(int i = 0; i<= PIXEL_VAL_MAX; i++) {
        LUT[i] = std::pow(LUT[i], gamma) * factor + shift;
        LUT[i] = Correction::boundariesCheck(LUT[i]);
    }

    if (image->format() == QImage::Format_Indexed8)
    {
        for (int x=0; x<width; x++)
            for (int y=0; y<height; y++)
            {
                QRgb pixel = image->pixel(x,y);
                int v = qGray(pixel);
                newImage->setPixel(x, y, LUT[v]);
            }
    }
    else if (image->format() == QImage::Format_RGB32)
    {
        for (int x=0; x<width; x++)
            for (int y=0; y<height; y++)
            {
                QRgb pixel = image->pixel(x,y);

                int r = qRed(pixel);
                int g = qGreen(pixel);
                int b = qBlue(pixel);

                QColor newPixel = QColor(LUT[r], LUT[g], LUT[b]);
                newImage->setPixel(x, y, newPixel.rgb());
            }
    }

    return newImage;
}
开发者ID:AirsickPayload,项目名称:pto_MiniGimpAMBM,代码行数:49,代码来源:correction.cpp

示例5: PNM

PNM* BinarizationGradient::transform()
{
    int width = image->width();
    int height = image->height();

    PNM* newImage = new PNM(width, height, QImage::Format_Mono);

    QRgb pixel;
    int top = 0;
    int bottom = 0;
    int gradientx = 0;
    int gradienty = 0;
    int gradient = 0;
    int temp = 0;

    for (int x=0; x<width; ++x)
    {
        for (int y=0; y<height; ++y)
        {
            QRgb pixel0 = image->pixel(x-1>=0 ? x-1 : x, y);
            QRgb pixel1 = image->pixel(x+1 < width ? x+1 : x, y);
            gradientx = qGray(pixel1) - qGray(pixel0);

            pixel0 = image->pixel(x, y-1>=0 ? y-1 : y);
            pixel1 = image->pixel(x, y+1<height ? y+1 : y);
            gradienty = qGray(pixel1) - qGray(pixel0);

            if (gradientx >= gradienty) {
                gradient = gradientx;
            }else{
                gradient = gradienty;
            }

            pixel = image->pixel(x, y);
            top += qGray(pixel) * gradient;
            bottom += gradient;
            temp = bottom==0 ? 0 : top / bottom;

            if (qGray(pixel) >= temp){
                newImage->setPixel(x, y, Qt::color1);
            }else{
                newImage->setPixel(x, y, Qt::color0);
            }
        }
    }

    return newImage;
}
开发者ID:nitz14,项目名称:pto2014_przetwarzanie,代码行数:48,代码来源:bin_gradient.cpp

示例6: PNM

PNM* BinarizationGradient::transform()
{
    int width = image->width();
    int height = image->height();

    PNM* newImage = new PNM(width, height, QImage::Format_Mono);

	Mode mode = RepeatEdge;
	int licz = 0, mian = 0;
	for (int x = 0; x < width; x++)
	{
		for (int y = 0; y < height; y++)
		{
			int value_pixel, G, Gx, Gy;
			QRgb pixel = getPixel(x, y, mode);
			value_pixel = qGray(pixel);
			Gx = qGray(this->getPixel(x + 1, y, mode)) - qGray(this->getPixel(x - 1, y, mode));
			Gy = qGray(this->getPixel(x, y + 1, mode)) - qGray(this->getPixel(x, y - 1, mode));
			if (Gx > Gy) {
				G = Gx;
			}
			else{
				G = Gy;
			}
			licz += value_pixel * G;
			mian += G;
		}
	}
	int threshold = licz / mian;
	
	for (int x = 0; x < width; x++)
	{
		for (int y = 0; y < height; y++)
		{
			QRgb pixel = image->pixel(x, y);
			int value_pixel = qGray(pixel);
			if (value_pixel < threshold){
				newImage->setPixel(x, y, 0);
			}
			else{
				newImage->setPixel(x, y, 1);
			}
		}
	}

    return newImage;
}
开发者ID:zlotylesk,项目名称:pto2014_KK,代码行数:47,代码来源:bin_gradient.cpp

示例7: PNM

PNM* BinarizationGradient::transform()
{
	int width = image->width();
	int height = image->height();

	PNM* newImage = new PNM(width, height, QImage::Format_Mono);

	int top = 0, bot = 0, tym = 0, grx = 0, gry = 0, gra = 0;
	for (int x = 0; x < width; ++x)
	{
		for (int y = 0; y < height; ++y)
		{
			QRgb pix, pix1, pix2;
			pix1 = getPixel(x - 1, y, RepeatEdge);
			pix2 = getPixel(x + 1, y, RepeatEdge);
			grx = qGray(pix2) - qGray(pix1);
			pix1 = getPixel(x, y - 1, RepeatEdge);
			pix2 = getPixel(x, y + 1, RepeatEdge);
			gry = qGray(pix2) - qGray(pix1);
			if (grx >= gry)
			{
				gra = grx;
			}
			else {
				gra = gry;
			}
			pix = getPixel(x, y, RepeatEdge);
			top += qGray(pix) * gra;
			bot += gra;
			tym = bot == 0 ? 0 : top / bot;
			if (qGray(pix) >= tym)
			{
				newImage->setPixel(x, y, Qt::color1);
			}
			else
			{
				newImage->setPixel(x, y, Qt::color0);
			}
		}
	}


	return newImage;
}
开发者ID:GrzKon,项目名称:pto2014_-lazarskiGIMP,代码行数:44,代码来源:bin_gradient.cpp

示例8: getParameter

PNM* MapNormal::transform()
{
    int width  = image->width(),
        height = image->height();

    double strength = getParameter("strength").toDouble();

    PNM* newImage = new PNM(width, height, image->format());

    //qDebug() << Q_FUNC_INFO << "Not implemented yet!";

    MapHeight* mh = new MapHeight(image);
    PNM* imgHeight = mh->transform();

    EdgeSobel* es = new EdgeSobel(image);
    math::matrix<float>* Gx = es->rawHorizontalDetection();
    math::matrix<float>* Gy = es->rawVerticalDetection();

    for (int i = 0; i < width; i++)
        for (int j = 0; j < height; j++) {

            float dx = (*Gx)(i,j)/255;
            float dy = (*Gy)(i,j)/255;
            float dz = 1/strength;

            double dw = sqrt(dx*dx + dy*dy + dz*dz);
            dx = dx / dw;
            dy = dy / dw;
            dz = dz / dw;

            dx = (dx + 1.0)*(255/strength);
            dy = (dy + 1.0)*(255/strength);
            dz = (dz + 1.0)*(255/strength);

            QColor newPixel = QColor(dx,dy,dz);
            newImage->setPixel(i,j, newPixel.rgb());

        }

    return newImage;
}
开发者ID:pandaive,项目名称:pto_takifajnyprojekt,代码行数:41,代码来源:map_normal.cpp

示例9: PNM

PNM* ConversionGrayscale::transform()
{
   // qDebug() << Q_FUNC_INFO << "Not implemented yet!";

    int width = image->width();
    int height = image->height();

    PNM* newImage = new PNM(width, height, QImage::Format_Indexed8);

    if (image->format() == QImage::Format_Mono)
    {
		for (int x = 0; x<width; x++)
			for (int y = 0; y<height; y++)
			{
			QColor color = QColor::fromRgb(image->pixel(x, y)); // Getting the pixel(x,y) value

			newImage->setPixel(x, y, color == Qt::white ? Qt::color1 : Qt::color0);
			}

    }
    else // if (image->format() == QImage::Format_RGB32)
    {
		for (int x = 0; x<width; x++)
			for (int y = 0; y<height; y++)
			{
			QRgb pixel = image->pixel(x, y); // Getting the pixel(x,y) value

			int r = qRed(pixel);    // Get the 0-255 value of the R channel
			int g = qGreen(pixel);  // Get the 0-255 value of the G channel
			int b = qBlue(pixel);   // Get the 0-255 value of the B channel
			r = (int) floor(r*0.3);
			g = (int) floor(g*0.6);
			b = (int) floor(b*0.1);
			//QColor newPixel = QColor(r, g, b);
			newImage->setPixel(x, y, r + g + b);
			}

    }

    return newImage;
}
开发者ID:GrzKon,项目名称:pto2014_-lazarskiGIMP,代码行数:41,代码来源:conversion_grayscale.cpp

示例10: getParameter

PNM* MapNormal::transform()
{
    int width  = image->width(),
        height = image->height();

    double strength = getParameter("strength").toDouble();

    PNM* newImage = new PNM(width, height, image->format());
    PNM* tempImage = MapHeight(image).transform();

    EdgeSobel sobel(tempImage);
    math::matrix<float>* Gx = sobel.rawHorizontalDetection();
    math::matrix<float>* Gy = sobel.rawVerticalDetection();

    newImage = new PNM(width, height, QImage::Format_RGB32);

    for(int i=0; i<width; i++)
    {
         for(int j=0; j<height; j++)
         {
             double dx = (*Gx)(i,j)/PIXEL_VAL_MAX;
             double dy = (*Gy)(i,j)/PIXEL_VAL_MAX;
             double dz = 1/strength;

             double length = sqrt(dx*dx + dy*dy + dz*dz);
             dx = dx/length;
             dy = dy/length;
             double dZ = dz/length;

             double t = 255/strength;
             dx = (dx + 1.0)* t;
             dy = (dy + 1.0)* t;
             dZ = (dZ + 1.0)* t;

             newImage->setPixel(i,j,qRgb(dx,dy,dZ));
         }
     }

    return newImage;
}
开发者ID:irmina90,项目名称:pto2014_klozie,代码行数:40,代码来源:map_normal.cpp

示例11: getParameter

PNM* Correction::transform()
{
    float shift  = getParameter("shift").toFloat();
    float factor = getParameter("factor").toFloat();
    float gamma  = getParameter("gamma").toFloat();

    int width  = image->width();
    int height = image->height();

    PNM* newImage = new PNM(width, height, image->format());

    for (int i=0; i<PIXEL_VAL_MAX+1; i++)
    {
        LUT[i] = i;
        LUT[i] += shift;
        LUT[i] *= factor;
        LUT[i] = pow(LUT[i],gamma);

        LUT[i] = LUT[i] > 255 ? 255 : LUT[i];
        LUT[i] = LUT[i] < 0 ? 0 : LUT[i];
    }

    for (int x=0; x<width; x++)
        for (int y=0; y<height; y++)
        {
            QRgb pixel = image->pixel(x,y); // Getting the pixel(x,y) value

            int r = qRed(pixel);    // Get the 0-255 value of the R channel
            int g = qGreen(pixel);  // Get the 0-255 value of the G channel
            int b = qBlue(pixel);   // Get the 0-255 value of the B channel

            QColor newPixel = QColor(LUT[r],LUT[g],LUT[b]);
            newImage->setPixel(x,y, newPixel.rgb());
        }

    return newImage;
}
开发者ID:nitz14,项目名称:pto2014_przetwarzanie,代码行数:37,代码来源:correction.cpp

示例12: getParameter

PNM* MapNormal::transform()
{
    int width  = image->width(),
        height = image->height();

    double strength = getParameter("strength").toDouble();

    PNM* newImage = new PNM(width, height, image->format());

	PNM* heightImage = MapHeight(image).transform();

	math::matrix<double>* G_x = EdgeSobel(heightImage).rawHorizontalDetection();
	math::matrix<double>* G_y = EdgeSobel(heightImage).rawVerticalDetection();

	for (int i=0; i<width;i++) {
		for (int j=0; j<height;j++) {
			double gx = (*G_x)(i,j);
			double gy = (*G_y)(i,j);
			double dX = gx/255;
			double dY = gy/255;
			double dZ = 1/strength;
			double length = sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2));
			dX/=length;
			dY/=length;
			dZ/=length;
			double r = (dX + 1.0)*(255/strength);
			double g = (dY + 1.0)*(255/strength);
			double b = (dZ + 1.0)*(255/strength);
			
			QColor newPixel = QColor(r,g,b);
			newImage->setPixel(i,j, newPixel.rgb());

		}
	}

    return newImage;
}
开发者ID:pto2013ErasmusStudents,项目名称:Image-Processing,代码行数:37,代码来源:map_normal.cpp

示例13: PNM

PNM* NoiseBilateral::transform()
{
    int width  = image->width();
    int height = image->height();

    PNM* newImage = new PNM(width, height, image->format());

    sigma_d = getParameter("sigma_d").toInt();
    sigma_r = getParameter("sigma_r").toInt();
    radius = sigma_d;
    Mode mode = RepeatEdge;
    QRgb pixel;
    int r,g,b;
    if(image->format() == QImage::Format_RGB32){
        for(int x=0;x<width;x++){
            for(int y=0;y<height;y++){
                pixel = getPixel(x,y,mode);

                r=calcVal(x,y,RChannel);
                g=calcVal(x,y,GChannel);
                b=calcVal(x,y,BChannel);
                QColor newPixel = QColor(r,g,b);
                newImage->setPixel(x,y,newPixel.rgb());
            }
        }
    }
    else if(image->format() == QImage::Format_Indexed8){
        for(int x=0;x<width;x++){
            for(int y=0;y<height;y++){
                int temp = calcVal(x,y,LChannel);
                newImage->setPixel(x,y,temp);
            }
        }
    }
    return newImage;
}
开发者ID:nitz14,项目名称:pto2014_przetwarzanie,代码行数:36,代码来源:noise_bilateral.cpp

示例14: getParameter

PNM* HoughLines::transform()
{
    // Cut of value from the image;
    int  threshold      = getParameter("threshold").toInt();
    bool drawWholeLines = getParameter("draw_whole_lines").toBool();

    PNM* newImage = new PNM(image->copy());

    EdgeLaplacian* edgeLaplacian = new EdgeLaplacian(image);
    edgeLaplacian->setParameter("size", 3);
    image = edgeLaplacian->transform();
    delete edgeLaplacian;

    BinarizationGradient* binGradient = new BinarizationGradient(image);
    image = binGradient->transform();
    delete binGradient;

    Hough* hough = new Hough(image);
    hough->setParameter("theta_density" , 3);
    hough->setParameter("skip_edge_detection", true);
    image = hough->transform();
    delete hough;

    int width  = image->width(),
        height = image->height();

    for (int theta = 0; theta < width; theta++) {
        for (int rho = 0; rho < height; rho++) {
            QRgb pixel = image->pixel(theta, rho);
            if(qGray(pixel) > threshold)
                newImage->setPixel(theta, rho, 1);
       }
    }

    return newImage;
}
开发者ID:FilipKowalski,项目名称:mygimp-imageprocessing-project,代码行数:36,代码来源:hough_lines.cpp

示例15: CornerHarris

PNM* HoughRectangles::transform()
{
	PNM* img = CornerHarris(image).transform();

	for (int i = 0; i < img->width(); i++)
	{
		for (int j = 0; j < img->height(); j++)
		{
			QColor color = QColor::fromRgb(img->pixel(i, j));
			if (color.black() != 255)
			{
				img = remove(i, j, i, j, img);
			}
		}
	}

	std::vector<std::pair<int, int>> points;

	for (int i = 0; i < img->width(); i++)
	{
		for (int j = 0; j < img->height(); j++)
		{
			QColor color = QColor::fromRgb(img->pixel(i, j));
			if (color.black() != 255)
			{
				points.push_back(std::make_pair(i, j));
			}
		}
	}

	for (int i = 0; i < points.size(); i++)
	{
		std::vector<std::pair<int, int>> corners = check_quadrat(points.at(i), img);
		if (corners.size() == 4)
		{
			img = drawQuadrat(corners, img);
		}
	}

    return img;
}
开发者ID:zlotylesk,项目名称:pto2014_KK,代码行数:41,代码来源:hough_rectangles.cpp


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