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 9223831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:10:04+00:00 2026-06-18T04:10:04+00:00

Ive been working on this project for days now and for some reason just

  • 0

Ive been working on this project for days now and for some reason just not able to get rid of an unexpected 1px by 1px (approx) white spot that apears in each and every tile that is processed.

Summary:

I am using an original image ( say original.jpeg ) as referance to create a mosaic image ( say mosaic.jpeg which is approx 1000px by 1000px ) by merging totegher much much smaller jpeg images ( aprox 10px by 10px ).

I have a data set of approx 20,000 tile images to work with.

Process so far

  1. I have mapped the original.jpeg image to cut it up into 5px by 5px tiles, then found the average color of each tile and saved it for further use.
  2. I have scanned all the (10×10) tile images and stored their individual average colors as well.
  3. i have calculated which tile image would fit closest to which tile of the original image by using Weighted ref : euclidean distance from the site mentioned.
  4. I have managed to use PHP gd library to create a new truecolor image with all the matching tiles placed in the right position ( thus effectively creating a mosaic of the original.jpeg image )

The Problem

I am not getting a clear mosaic i had expected, for some reason the tiles do not match properly.

The Workaround

Now due to lack of time i an using a quick fix where in i take the original image, give it some 50% opacity and overlay it on top of each tile while it is being placed into the final mosaic.

NOTE: Although i am effectively overlaying the original image over the mosaic image, im NOT doing it in one go. The overlaying HAS to happen at each tile level.

So in short : Before placing each tile at the correct position of the final mosaic, i do the following
1. get that particular section of the original image ( 5x5px )
2. expand it to match the final tile size ( 10x10px )
3. set transparency for the section
4. place it over the tile that will be placed
5. merge this new tile over the final mosaic at the corresponding position.

Here is the function i have created to overlay part of the image along with transparency set to it.

public function overlay($dImg, $sImg, $opacity = null) {

    // set default Opacity if not specified
    $opacity = (is_null($opacity)) ? $this->opacity : $opacity;

    // get width, height of sourceImage
    $sWidth = imagesx($sImg);
    $sHeight = imagesy($sImg);

    // get width height of final image
    $dWidth = imagesx($dImg);
    $dHeight = imagesy($dImg);

    $image = imagecreatetruecolor($dWidth, $dHeight);
    imagecopyresampled($image, $sImg, 0, 0, 0, 0, $dWidth, $dHeight, $sWidth, $sHeight);

    $background = imagecolorallocatealpha($image, 255, 255, 255, 127);        
    imagefill($image, 0, 0, $background);

    imagealphablending($image, true);

    imagecopymerge($dImg, $image, 0, 0, 0, 0, $dWidth, $dHeight, $opacity);

    imagedestroy($image);

    return $dImg;
}

THE REAL PROBLEM

in theory all of this seems perfectly fine. But the results have their own say in the matter.

I noticed an unusual almost 1x1px white patch at the start of every tile of the final mosaic.

This white patch only appears when the transparency technique above is applied. It does not happen otherwise.

I am clueless as to why this is happening, Due to this white patch the entire image looks like it has white noise all over it and degrades the overall quality immensely.

Please guide me in any direction as to why something like this could be happening.

  • 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-18T04:10:05+00:00Added an answer on June 18, 2026 at 4:10 am

    your problem lies on these two lines:

    $background = imagecolorallocatealpha($image, 255, 255, 255, 127);        
    imagefill($image, 0, 0, $background);
    

    you don’t need those, because imagefill is used to fill an area that have same/similar color with the color located on the supplied coordinate, in your case 0, 0 (top left), when there is no adjacent similar color, then it just change the color at the given coordinate.

    you can use imagefilledrectangle instead, but i still think you don’t need that, just comment out those 2 lines and see the result if it match your requirement, if not, then go ahead use imagefilledrectangle

    imagefilledrectangle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been working on this for two days, can't get it, I need some
I've been working on this project for about two weeks now. I don't understand
I've been working on this for a couple of days now without success. Basically,
I've been working at this for two days and have not had much luck.
I've been working on this project for about a year now. It's a basic
I've been working with Maven for days but still get confused about some of
I've been working on this project for about a week now and I've been
I've been working on this project for a few days and I really haven't
I've been working on a project for 4 days now, completely written by hand,
Ive been working on a C# project for a while now and I fell

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.