Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7992283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:31:07+00:00 2026-06-04T13:31:07+00:00

I have a problem.. There is some picture, like this: and I want to

  • 0

I have a problem..
There is some picture, like this:

enter image description here

and I want to add a new resolution, background, and better quality ( antialias) to this radar image. How can I get radar details from this image with a PHP script?

I have already this code, but the output isnt the best :S you can see it here:

enter image description here

<?
$im = imagecreatefromjpeg('a.jpg');
$f1 = imagecolorallocate($im, 39, 78, 231); 
$a = imagecreatetruecolor ( 520, 370 );
$red = imagecolorallocate($a, 39,78,231); 
for($x =130;$x<520;$x++)
{
for($y = 130; $y<370;$y++)
{
    $rgb = imagecolorat($im, $x, $y);
    $r = ($rgb >> 16) & 0xFF;
    $g = ($rgb >> 8) & 0xFF;
    $b = $rgb & 0xFF;

    $red = imagecolorallocate($a, $r,$g,$b); 
    //echo $r.$     g.$b."|";

    if( ($r < 100 && $r > 0) && ($g < 150 && $g > 0) && ($b < 255 && $b > 150))
        imagesetpixel($a, $x, $y, $red);
    if( ($r < 100 && $r > 0) && ($g < 255 && $g > 130) && ($b < 255 && $b > 0))
        imagesetpixel($a, $x, $y, $red);
    if( ($r < 200 && $r > 100) && ($g < 255 && $g > 180) && ($b < 80 && $b > 0))
        imagesetpixel($a, $x, $y, $red);
    if( ($r < 255 && $r > 0) && ($g < 255 && $g > 0) && ($b < 50 && $b > 0))
        imagesetpixel($a, $x, $y, $red);
    if( ($r < 255 && $r > 200) && ($g < 255 && $g > 70) && ($b < 70 && $b > 0))
        imagesetpixel($a, $x, $y, $red);
    if( ($r < 255 && $r > 200) && ($g < 100 && $g > 0) && ($b < 70 && $b > 0))
        imagesetpixel($a, $x, $y, $red);
    if( ($r < 120 && $r > 0) && ($g < 50 && $g > 0) && ($b < 50 && $b > 0))
        imagesetpixel($a, $x, $y, $red);
}
} 
//$rgb = imagecolorat($im, 550, 465);
//$r = ($rgb >> 16) & 0xFF;
//$g = ($rgb >> 8) & 0xFF;
//$b = $rgb & 0xFF;
//echo "$r $g $b";
header('Content-Type: image/png');
imagepng($a);
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:31:08+00:00Added an answer on June 4, 2026 at 1:31 pm

    replace kép.jpg with image. 1st try. I think I can adjust things to get closer.

    2nd try: floor seems to be much better than round.

    3rd try: added 2 filters to the code.

    <?php
    header('content-type: image/png');
    //header('content-type: text/plain');
    
    
    $im = imagecreatefromjpeg ('images/a.jpg');
    list($width, $height, $type, $attr) = getimagesize('images/a.jpg');
    
    $im2 = imagecreate($width, $height);
    
    $x = 540;
    $y = 353;
    
    $colors = array();
    
    
    $num = 100;
    $num2 = 15 * 11 * $num;
    $num3 = 100;
    
    $num4 = 65;
    $num5 = 15 * 11 * $num4;
    $num6 = 65;
    
    imagecolorallocate($im2, 255, 255, 255);
    for ($k = 0; $k < 7; $k ++) {
        $ar = 0;
        $ag = 0;
        $ab = 0;
    
        for ($i = 0; $i < 15; $i ++) {
            for ($j = 0; $j < 11; $j ++) {
                $tc = imagecolorat($im, $x + $i, $y + $j + $k * 18);
                $ar += ($tc >> 16) & 0xFF;
                $ag += ($tc >> 8) & 0xFF;
                $ab += $tc & 0xFF;
            }
        }
    
        $c = new STDClass();
        if ($k == 0) {
            $c->r = floor ($ar / $num5) * $num4;
            $c->g = floor ($ag / $num5) * $num4;
            $c->b = floor ($ab / $num5) * $num4;
        } else {
            $c->r = floor ($ar / $num2) * $num;
            $c->g = floor ($ag / $num2) * $num;
            $c->b = floor ($ab / $num2) * $num;
        }
    
        $c->c = imagecolorallocate($im2, $c->r, $c->g, $c->b);
    
        $colors[] = $c;
    
        imagefilledrectangle($im2, 0, $k * 11, 15, $k * 11 + 11, $c->c);
    }
    
    
    $pixelmap = array();
    $pm2 = array();
    for ($i = 0; $i < $width; $i ++) {
        $pixelmap[$i] = array();
        $pm2[$i] = array();
        for ($j = 0; $j < $height; $j ++) {
            $pixelmap[$i][$j] = false;
            $pm2[$i][$j] = false;
            $c = imagecolorat($im, $i, $j);
    
            $r = ($c >> 16) & 0xFF;
            $g = ($c >> 8) & 0xFF;
            $b = $c & 0xFF;
    
            $r = floor ($r / $num3) * $num3;
            $g = floor ($g / $num3) * $num3;
            $b = floor ($b / $num3) * $num3;
    
            $r2 = floor ($r / $num6) * $num6;
            $g2 = floor ($g / $num6) * $num6;
            $b2 = floor ($b / $num6) * $num6;
    
    
            for ($k = 0; $k < 7; $k ++) {
                $colorOK = true;
                if ($k == 0) {
                    if ($r2 != $colors[$k]->r) { $colorOK = false; }
                    if ($g2 != $colors[$k]->g) { $colorOK = false; }
                    if ($b2 != $colors[$k]->b) { $colorOK = false; }
                } else {
                    if ($r != $colors[$k]->r) { $colorOK = false; }
                    if ($g != $colors[$k]->g) { $colorOK = false; }
                    if ($b != $colors[$k]->b) { $colorOK = false; }
                }
                if ($colorOK) { break; }
            }
    
    
            if ($k < 7) { // else no mathing color was found
                $pixelmap[$i][$j] = $colors[$k]->c;
                //imagesetpixel($im2, $i, $j, $pixelmap[$i][$j]);
            }
        }
    }
    
    
    for ($i = 1; $i < $width - 1; $i ++) {
        for ($j = 1; $j < $height - 1; $j ++) {
            if ($pixelmap[$i][$j] !== false) {
                if ($pixelmap[$i    ][$j - 1] !== false ||
                    $pixelmap[$i + 1][$j - 1] !== false ||
                    $pixelmap[$i + 1][$j    ] !== false ||
                    $pixelmap[$i + 1][$j + 1] !== false ||
                    /*$pixelmap[$i  ][$j + 1] !== false ||*/
                    $pixelmap[$i - 1][$j + 1] !== false ||
                    $pixelmap[$i - 1][$j    ] !== false) {
                    //imagesetpixel($im2, $i, $j, $pixelmap[$i][$j]);
                } else {
                    $pixelmap[$i][$j] = false;
                }
                $pm2[$i][$j] = $pixelmap[$i][$j];
            } else {
                $surroundColors = array();
                if (isset($surroundColors[$pixelmap[$i - 1][$j - 1]])) { $surroundColors[$pixelmap[$i - 1][$j - 1]]++; } else { $surroundColors[$pixelmap[$i - 1][$j - 1]] = 1; };
                if (isset($surroundColors[$pixelmap[$i    ][$j - 1]])) { $surroundColors[$pixelmap[$i    ][$j - 1]]++; } else { $surroundColors[$pixelmap[$i    ][$j - 1]] = 1; };
                if (isset($surroundColors[$pixelmap[$i + 1][$j - 1]])) { $surroundColors[$pixelmap[$i + 1][$j - 1]]++; } else { $surroundColors[$pixelmap[$i + 1][$j - 1]] = 1; };
                if (isset($surroundColors[$pixelmap[$i + 1][$j    ]])) { $surroundColors[$pixelmap[$i + 1][$j    ]]++; } else { $surroundColors[$pixelmap[$i + 1][$j    ]] = 1; };
                if (isset($surroundColors[$pixelmap[$i + 1][$j + 1]])) { $surroundColors[$pixelmap[$i + 1][$j + 1]]++; } else { $surroundColors[$pixelmap[$i + 1][$j + 1]] = 1; };
                if (isset($surroundColors[$pixelmap[$i    ][$j + 1]])) { $surroundColors[$pixelmap[$i    ][$j + 1]]++; } else { $surroundColors[$pixelmap[$i    ][$j + 1]] = 1; };
                if (isset($surroundColors[$pixelmap[$i - 1][$j + 1]])) { $surroundColors[$pixelmap[$i - 1][$j + 1]]++; } else { $surroundColors[$pixelmap[$i - 1][$j + 1]] = 1; };
                if (isset($surroundColors[$pixelmap[$i - 1][$j    ]])) { $surroundColors[$pixelmap[$i - 1][$j    ]]++; } else { $surroundColors[$pixelmap[$i - 1][$j    ]] = 1; };
    
                $c = array_keys ($surroundColors);
                $pm2[$i][$j] = ($c[0] == false ? false : $c[0]);
                //imagesetpixel($im2, $i, $j, $c[0]);
            }
        }
    }
    
    $pixelmap = $pm2;
    for ($i = 1; $i < $width - 1; $i ++) {
        for ($j = 1; $j < $height - 1; $j ++) {
            if ($pixelmap[$i][$j] !== false) {
                if ($pixelmap[$i    ][$j - 1] !== false ||
                    $pixelmap[$i + 1][$j - 1] !== false ||
                    $pixelmap[$i + 1][$j    ] !== false ||
                    $pixelmap[$i + 1][$j + 1] !== false ||
                    /*$pixelmap[$i  ][$j + 1] !== false ||*/
                    $pixelmap[$i - 1][$j + 1] !== false ||
                    $pixelmap[$i - 1][$j    ] !== false) {
                    imagesetpixel($im2, $i, $j, $pixelmap[$i][$j]);
                } else {
                    $pixelmap[$i][$j] = false;
                }
            } else {
                $surroundColors = array();
                if (isset($surroundColors[$pixelmap[$i - 1][$j - 1]])) { $surroundColors[$pixelmap[$i - 1][$j - 1]]++; } else { $surroundColors[$pixelmap[$i - 1][$j - 1]] = 1; };
                if (isset($surroundColors[$pixelmap[$i    ][$j - 1]])) { $surroundColors[$pixelmap[$i    ][$j - 1]]++; } else { $surroundColors[$pixelmap[$i    ][$j - 1]] = 1; };
                if (isset($surroundColors[$pixelmap[$i + 1][$j - 1]])) { $surroundColors[$pixelmap[$i + 1][$j - 1]]++; } else { $surroundColors[$pixelmap[$i + 1][$j - 1]] = 1; };
                if (isset($surroundColors[$pixelmap[$i + 1][$j    ]])) { $surroundColors[$pixelmap[$i + 1][$j    ]]++; } else { $surroundColors[$pixelmap[$i + 1][$j    ]] = 1; };
                if (isset($surroundColors[$pixelmap[$i + 1][$j + 1]])) { $surroundColors[$pixelmap[$i + 1][$j + 1]]++; } else { $surroundColors[$pixelmap[$i + 1][$j + 1]] = 1; };
                if (isset($surroundColors[$pixelmap[$i    ][$j + 1]])) { $surroundColors[$pixelmap[$i    ][$j + 1]]++; } else { $surroundColors[$pixelmap[$i    ][$j + 1]] = 1; };
                if (isset($surroundColors[$pixelmap[$i - 1][$j + 1]])) { $surroundColors[$pixelmap[$i - 1][$j + 1]]++; } else { $surroundColors[$pixelmap[$i - 1][$j + 1]] = 1; };
                if (isset($surroundColors[$pixelmap[$i - 1][$j    ]])) { $surroundColors[$pixelmap[$i - 1][$j    ]]++; } else { $surroundColors[$pixelmap[$i - 1][$j    ]] = 1; };
    
                $c = array_keys ($surroundColors);
                //$pixelmap[$i][$j] = $c[0];
                imagesetpixel($im2, $i, $j, $c[0]);
            }
        }
    }
    
    
    
    imagepng ($im2);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem where I have some html like this <p>There is the
I have some problem with Android AsyncTask. There is an Activity which contains some
Propose to consider the following problem. Suppose we have some composite object. Are there
what's the problem there, I have uploaded this video to server, but now its
I'm having a problem with an image and some text. I have this code:
Okay, I have a problem with my code. I want to make some sort
This is a big-picture question... but I also have details on the problem I
I have some localization problems in my webpage. There are basically two problems (that
i have problem with libhid . i found that there 2 way 4 accessing
I have problem with lazy loading in many-to-many. There is no exception and there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.