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


C++ ImageRGB::height方法代码示例

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


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

示例1: filterImage

void YellowColorFilter::filterImage(ImageRGB & image) {
	// Image size;
	int width = image.width();
	int height = image.height();

	// For every pixel in the image
	for (int y = 0; y < height; y++) {
		for (int x = 0; x < width; x++) {
			// Get the RGB values
			Rgb<unsigned char &> pixelRGB = image.at(x, y);

			// To save the Hue, Saturation and Value
			float hue, saturation, value;

			// Convert RGB to HSV.
			RGB2HSV(pixelRGB.red, pixelRGB.green, pixelRGB.blue, hue, saturation, value);

			// If the color is yellow.
			if (hue >= 25 && hue <= 60 && saturation >= 0.60) {
				// If the color is within our yellow range, make the output pixel white.
				pixelRGB.red = 255;
				pixelRGB.green = 255;
				pixelRGB.blue = 255;
			}
			else {
				// Else make the pixel black.
				pixelRGB.red = 0;
				pixelRGB.green = 0;
				pixelRGB.blue = 0;
			}
		}
	}
}
开发者ID:bryanbaan,项目名称:Themaopdracht-07---Lokalisatie-2,代码行数:33,代码来源:YellowColorFilter.cpp

示例2: convertToGrayscale

ImageGray GrayscaleImage::convertToGrayscale(ImageRGB & image) {
	// Image size.
	int width = image.width();
	int height = image.height();

	// The destination image.
	ImageGray grayImage(width, height);

	// For every pixel in the image.
	for (int y = 0; y < height; y++) {
		for (int x = 0; x < width; x++) {
			// Get the pixel at position x,y.
			Rgb<unsigned char &> pixelRGB = image.at(x, y);
			unsigned char& pixelGray = grayImage.at(x, y);

			// Convert RGB to grayscale.
			pixelGray = pixelRGB.red * 0.114 + pixelRGB.green * 0.587 + pixelRGB.blue * 0.299;
		}
	}
	
	// Return the gray image.
	return grayImage;
}
开发者ID:bryanbaan,项目名称:Themaopdracht-07---Lokalisatie-2,代码行数:23,代码来源:GrayscaleImage.cpp

示例3: saveImg

	void saveImg(const ImageRGB & img, const std::string filename)
	{
		CImg<unsigned char> cimg(img.data(0, 0, Channel::Red), img.width(), img.height(), 1, 3);

		cimg.save(filename.c_str());
	}
开发者ID:ngf-koster,项目名称:THO7-OCR-Team2,代码行数:6,代码来源:ImageLoader.cpp

示例4: if

std::unique_ptr<ImageGray> thresholdDetermination::convert(const ImageRGB& img){
	std::unique_ptr<ImageGray> returnImage = std::make_unique<ImageGray>(img.width(), img.height());
	meanCorners = (getIntensity(convertToHex(img.at(0, 0).red, img.at(0, 0).green, img.at(0, 0).blue)) + getIntensity(convertToHex(img.at(img.width() - 1, 0).red, img.at(img.width() - 1, 0).green, img.at(img.width() - 1, 0).blue)) + getIntensity(convertToHex(img.at(0, img.height() - 1).red, img.at(0, img.height() - 1).green, img.at(0, img.height() - 1).blue))) + getIntensity(convertToHex(img.at(img.width() - 1, img.height() - 1).red, img.at(img.width() - 1, img.height() - 1).green, img.at(img.width() - 1, img.height() - 1).blue)) / 4;
	meanAllOthers = 0;

	for (int h = 0; h < img.height(); ++h) {
		for (int w = 0; w < img.width(); ++w) {

			if (!((w == 0 && h == 0) || (w == img.width() - 1 && h == 0) || (w == 0 && h == img.height() - 1) || (w == img.width() - 1 && h == img.height() - 1))) {
				meanAllOthers += getIntensity(convertToHex(img.at(w, h).red, img.at(w, h).green, img.at(w, h).blue));
			}

		}
	}

	meanAllOthers /= ((img.width()*img.height()) - 4);

	tOld = 0;
	tNew = (meanCorners + meanAllOthers) / 2;


	unsigned int u1count = 0, u2count = 0;

	while (tNew != tOld) {

		meanAllOthers = 0;
		meanCorners = 0;
		for (int h = 0; h < img.height(); ++h) {
			for (int w = 0; w < img.width(); ++w) {


				if (getIntensity(convertToHex(img.at(w, h).red, img.at(w, h).green, img.at(w, h).blue)) < tNew){
					meanCorners += getIntensity(convertToHex(img.at(w, h).red, img.at(w, h).green, img.at(w, h).blue));
					u1count++;
				}
				else if (getIntensity(convertToHex(img.at(w, h).red, img.at(w, h).green, img.at(w, h).blue)) >= tNew){
					meanAllOthers += getIntensity(convertToHex(img.at(w, h).red, img.at(w, h).green, img.at(w, h).blue));
					u2count++;
				}

			}
		}
		if (u1count != 0){ 
			meanCorners /= u1count;		// HOTFIX - lars u1count kan nul zijn....
		}
		if (u2count != 0){
			meanAllOthers /= u2count;	// HOTFIX - lars u2count kan nul zijn....
		}
		
		u1count = 0;
		u2count = 0;
		tOld = tNew;
		tNew = (meanCorners + meanAllOthers) / 2;

	}

	for (int h = 0; h < returnImage->height(); ++h) {
		for (int w = 0; w < returnImage->width(); ++w) {

			if (getIntensity(convertToHex(img.at(w, h).red, img.at(w, h).green, img.at(w, h).blue)) < tNew){
				returnImage->at(w, h) = 0;
			}
			else if (getIntensity(convertToHex(img.at(w, h).red, img.at(w, h).green, img.at(w, h).blue)) >= tNew){
				returnImage->at(w, h) = 255;
			}

		}
	}

	return returnImage;

}
开发者ID:madmilla,项目名称:Lazaretto,代码行数:72,代码来源:thresholdDetermination.cpp


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