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
Re: Help with PHP BD imaging functionality [message #182486 is a reply to message #182484] Thu, 08 August 2013 07:58 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
On 08/08/13 00:53, Ed Jay wrote:
> 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?

is the problem less that you don't know how to make GD do what you want,
then you don't actually know how to do what you want at all?

Is what you want covered by this?

http://www.php.net/manual/en/image.examples.merged-watermark.php

>
> $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,


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
[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: Fri Nov 22 22:25:44 GMT 2024

Total time taken to generate the page: 0.04348 seconds