FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Help with PHP BD imaging functionality
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Help with PHP BD imaging functionality [message #182484] Wed, 07 August 2013 23:53 Go to previous message
Ed Jay is currently offline  Ed Jay
Messages: 7
Registered: August 2013
Karma:
Junior Member
I'm trying to highlight a portion of a grayscale image, with the
highlighting color applied to pixels within a range of level only. I'm not
getting the result I seek.

While the grayscale values within the range possibly yield the highlight
color, the entire image is masked with the color from the last
imagecolorallocate.

My code follows, and the 'Process of interest' is the offending culprit.

How do I highlight the value-region of interest with the background of my
choosing?

$source_image = $_GET['source'];
$threshold = $_GET['threshold'];
$range = $_GET['range'];

$starting_img = imagecreatefromjpeg($source_image);
$img_data = getimagesize($source_image);
$width = $img_data[0];
$height = $img_data[1];
$final = imagecreatetruecolor($img_data[0],$img_data[1]);

$gray_threshold = 1*$threshold;
$gray_range = 1*$range;
$gray_top = ($gray_threshold + $gray_range);
if ($gray_top > 255) {$gray_top = 255;}
$highlight_color = imagecolorallocate($final,0,0,255);

//Process of interest:

for($x=0; $x<$width; $x++){
for($y=0; $y<$height; $y++){

$gray =(imagecolorat($final,$x,$y) >> 16) & 0xFF;
if (($gray > $gray_threshold) && ($gray < $gray_top)) {$gray =
$highlight_color;}
$gray2 = imagecolorallocate($final,$gray,$gray,$gray);
imagesetpixel($final, $x,$y,$gray2);

}
}

header('Content-Type: image/jpeg');
imagejpeg($final);
imagedestroy($starting_img);
imagedestroy($final);

Thanks in advance,
--
Ed Jay (remove 'M' to respond by email)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: GUI designer in html
Next Topic: Dictionary Words
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 09:01:55 GMT 2024

Total time taken to generate the page: 0.04058 seconds