我有一幅画面,把照片翻一番,所有照片都用得很美,但我希望能够把颜色从照片中抹掉,留下黑白的图像(各种灰尘基本上)。 我肯定了如何实现这一目标?
增 编
我有一幅画面,把照片翻一番,所有照片都用得很美,但我希望能够把颜色从照片中抹掉,留下黑白的图像(各种灰尘基本上)。 我肯定了如何实现这一目标?
增 编
2. 遵循这些思路:
<?php
$source_file = "test_image.jpg";
$im = ImageCreateFromJpeg($source_file);
$imgw = imagesx($im);
$imgh = imagesy($im);
for ($i=0; $i<$imgw; $i++)
{
for ($j=0; $j<$imgh; $j++)
{
// get the rgb value for current pixel
$rgb = ImageColorAt($im, $i, $j);
// extract each value for r, g, b
$rr = ($rgb >> 16) & 0xFF;
$gg = ($rgb >> 8) & 0xFF;
$bb = $rgb & 0xFF;
// get the Value from the RGB value
$g = round(($rr + $gg + $bb) / 3);
// grayscale values have r=g=b=g
$val = imagecolorallocate($im, $g, $g, $g);
// set the gray value
imagesetpixel ($im, $i, $j, $val);
}
}
header( Content-type: image/jpeg );
imagejpeg($im);
?>
通知说,我无耻地从上渗入了这条,我发现该条使用了“ogle”搜索术语: php形象改为“graycal <>。
[ edit ] And from the comments, if you use PHP5, you could also use:
imagefilter($im, IMG_FILTER_GRAYSCALE);
The easiest solution is to use imagefilter($im, IMG_FILTER_GRAYSCALE); But every single method mentioned here is not working for 100%. All of them is counting on color palette of the image, but the shades of gray might be missing and another color from the palette is used.
我的解决办法是用图像col器替换彩色盒。
$colorsCount = imagecolorstotal($img->getImageResource());
for($i=0;$i<$colorsCount;$i++){
$colors = imagecolorsforindex( $img->getImageResource() , $i );
$g = round(($colors[ red ] + $colors[ green ] + $colors[ blue ]) / 3);
imagecolorset($img->getImageResource(), $i, $g, $g, $g);
}
例如:
$file = image.jpg ;
$file = image.gif ;
$file = image.png ;
$image_type = getimagesize($file);
switch (strtolower($image_type[ mime ])) {
case image/png :
exec("convert $file -colorspace Gray dummy.png");
break;
case image/jpeg :
exec("convert $file -colorspace Gray dummy.jpeg");
break;
case image/gif :
exec("convert $file -colorspace Gray dummy.gif");
break;
default:
die;
}
I am looking for a recommendation for an introduction to image processing algorithms (face and shape recognition, etc.) and wondered if anyone had an good recommendations, either for books, ...
I m looking for the fastest and more efficient method of detecting an object in a moving video. Things to note about this video: It is very grainy and low resolution, also both the background and ...
I am learning digital image processing on my own and would like recomendations on good reference books. If you know of books to definately stay away from that would be useful as well. Thanks
I have this image: I want to read it to a string using python, which I didn t think would be that hard. I came upon tesseract, and then a wrapper for python scripts using tesseract. So I started ...
I m building a site for a client that needs to support image uploads (an artist) through the admin interface. Since most of the images are pretty high-res, I wanted to create thumb copies of the image ...
I have an image processing routine that I believe could be made very parallel very quickly. Each pixel needs to have roughly 2k operations done on it in a way that doesn t depend on the operations ...
I m currently working on writing a version of the MATLAB RegionProps function for GNU Octave. I have most of it implemented, but I m still struggling with the implementation of a few parts. I had ...
I ve been implementing an adaptation of Viola-Jones face detection algorithm. The technique relies upon placing a subframe of 24x24 pixels within an image, and subsequently placing rectangular ...