Ditutup

PHP convert Image to RGB565, compress, show stat's and download

I am working on logic for a Microcontroller that dynamically updates a screen via UART. The screen only accepts vector based commands to fill a coordinate with a square and a filled color. The command looks like so

fill x,y,h,w,<color>

The PHP code I wrote so far takes the image and converts each pixel to the following format, However, there are tons of room for optimization. An idea I had was to take the image and find the most common color then set the whole screen to this color. Then find all pixel's within a given shade and make it the same color than that beings the fill command to a single command because it can then cover two squares by using the command x,y,2,1,<color>.

The goal is to generate the picture with lossy compression but without extremely affecting the image and as few FILL commands as possible.

During the development of these algorithms, your PHP code will need to display the before and after image and the number of FILL lines required to draw the image.

The Binary data of the x,y, color will then be sent as a .bin file when requested from the .php script.

It can be your own or someone else's algorithm.. just make it possible to redraw with least amount of commands

Examples of algorithms are like this.

Cycle through each pixel and neighboring pixels and if they are similar shade make them the same. Then find the most common color and set the background image to that color. then cycle through each pixel if it's not that background color fill in that color.

The least amount of times you have to cast the fill command to drop a pixel the better the algorithm!

A sample image that will be used is here

[login to view URL]

In this case, the large portion of the map is gray, so its best to make that shade one distinct RGB565 color then set the image of the full background to that color using a single fill command.

Then cycle through each pixel and combine additional like colors to make the least amount of permutations to cast a fill command to fill a pixel or a subset of pixels.

When doing this without any compression you would have to cast nearly one fill command for each pixel and would take over 5 minutes to draw a screen which is not a doable solution however there should be a simple way to go upon this.

Sample PHP code to get started.

<?php

$img = imagecreatefromjpeg("Path to Image that is 480x272");

$width = ImageSX($img);

$height = ImageSY($img);

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

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

$c = imageColorAt($img, $x, $y);

$r = ($c >> 16) & 0xFF;

$g = ($c >> 8) & 0xFF;

$b = $c & 0xFF;

$r = $r >> 3;

$g = $g >> 2;

$b = $b >> 3;

$oc = ($r << 11) | ($g << 5) | $b;

echo ("fill $x,$y,1,1,$oc<br>");

}

}

?>

Kemahiran: Algoritma, Image Processing, PHP, Kejuruteraan Perisian

Lihat lagi: php convert uploaded image to jpg, php print image, php show image, php return image, php image header, php jpeg compression, php image, php save image, convert image transparent php, image download database using php, image magic php convert round, php library convert image cmyk, php ocr convert image text, convert php jpeg image, form php convert url image, convert php link image, php convert image cur, convert image cur download descarga, php convert html div image, php convert swf image php

Tentang Majikan:
( 5 ulasan ) Palm Desert, United States

ID Projek: #19339774

8 pekerja bebas membida secara purata $180 untuk pekerjaan ini

techwelfare

We have gone through your long description....we are the one who could do this work. plz share every [login to view URL] want to discuss with you... plz do respond.

$210 USD dalam 8 hari
(159 Ulasan)
7.1
janggang

Hello. I am very pleasure the opportunity to discuss this job with you. I have reviewed your job posting carefully and knew what you are going to do. 8+ years’ experience on web development, Skilled on PHP and MVC Lagi

$150 USD dalam 3 hari
(27 Ulasan)
5.9
jarki2017

Hi I just read your job description carefully. I have 14+ years of experiences in PHP development, so this job is very easy for me. I think so, About me, please check my git - [login to view URL] Thanks

$133 USD dalam 3 hari
(37 Ulasan)
6.0
psubramonian

Waiting for your reply. My Portfolio: =========== - Corporate Company Website: [login to view URL] - iSmartTax : [login to view URL] - Samsung extremo : [login to view URL] - Insider TV : http://i Lagi

$250 USD dalam 2 hari
(98 Ulasan)
6.3
happyday2008drea

I have just seen your project description. I think I am one of the right persons who have the ability and skills you required. I am sure I can complete this algorithm using PHP. I can start work right away. I wil Lagi

$155 USD dalam 2 hari
(18 Ulasan)
5.3
artiboria

Hi, Thank you so much for the nice work opportunity. I am a Website and Mobile Application developer and having more than 12 years of experience in the industry. I do work on following technologies... Android Appli Lagi

$155 USD dalam 5 hari
(51 Ulasan)
5.5
ChaoHan2018

Dear Recruiter, I have 6+ years highly skilled dedicated in-house team knowledgeable in: Graphic & Web-Design | Bootstrap | Responsive HTML5 | PHP | Larevel | Codeignitor | Angular | ReactJS | VueJS | NodeJS | Java sp Lagi

$250 USD dalam 3 hari
(28 Ulasan)
5.1
$133 USD dalam 3 hari
(0 Ulasan)
0.0