Click here to Skip to main content
15,900,532 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Find the sublist of objects with the highest value without exceeding weight limit Pin
OriginalGriff27-Apr-19 2:25
mveOriginalGriff27-Apr-19 2:25 
GeneralRe: Find the sublist of objects with the highest value without exceeding weight limit Pin
Member 1433642827-Apr-19 5:29
Member 1433642827-Apr-19 5:29 
GeneralRe: Find the sublist of objects with the highest value without exceeding weight limit Pin
ChrisFromWales1-May-19 0:09
ChrisFromWales1-May-19 0:09 
GeneralRe: Find the sublist of objects with the highest value without exceeding weight limit Pin
Member 143364281-May-19 6:49
Member 143364281-May-19 6:49 
GeneralRe: Find the sublist of objects with the highest value without exceeding weight limit Pin
Richard Deeming1-May-19 8:09
mveRichard Deeming1-May-19 8:09 
GeneralRe: Find the sublist of objects with the highest value without exceeding weight limit Pin
Member 143364282-May-19 4:19
Member 143364282-May-19 4:19 
GeneralRe: Find the sublist of objects with the highest value without exceeding weight limit Pin
Member 143364281-May-19 11:09
Member 143364281-May-19 11:09 
QuestionAlgorithm to compress Image to RGB565 for embedded screen Pin
XxKeldecknightxX24-Apr-19 8:10
XxKeldecknightxX24-Apr-19 8:10 
Hi Everyone!!
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.

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
https://www.faichi.com/sites/default/fi ... %202_0.png[^]

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.
<?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>");
    }
}
?>

If anyone has any Keyterms I may use to research this issue I'd be more then open to review them and any pointers in the right direction would be greatly appreciated!

Thanks everyone for your consideration!

modified 24-Apr-19 14:18pm.

AnswerRe: Algorithm to compress Image to RGB565 for embedded screen Pin
Gerry Schmitz24-Apr-19 8:56
mveGerry Schmitz24-Apr-19 8:56 
GeneralRe: Algorithm to compress Image to RGB565 for embedded screen Pin
XxKeldecknightxX24-Apr-19 11:21
XxKeldecknightxX24-Apr-19 11:21 
QuestionGet all groups in 4x4 matrix with width and height of power 2 Pin
Member 142151775-Apr-19 6:59
Member 142151775-Apr-19 6:59 
GeneralRe: Get all groups in 4x4 matrix with width and height of power 2 Pin
Richard MacCutchan5-Apr-19 8:51
mveRichard MacCutchan5-Apr-19 8:51 
GeneralRe: Get all groups in 4x4 matrix with width and height of power 2 Pin
Member 142151776-Apr-19 1:26
Member 142151776-Apr-19 1:26 
GeneralRe: Get all groups in 4x4 matrix with width and height of power 2 Pin
Richard MacCutchan6-Apr-19 4:32
mveRichard MacCutchan6-Apr-19 4:32 
GeneralRe: Get all groups in 4x4 matrix with width and height of power 2 Pin
Member 142151776-Apr-19 5:18
Member 142151776-Apr-19 5:18 
AnswerRe: Get all groups in 4x4 matrix with width and height of power 2 Pin
Gerry Schmitz6-Apr-19 10:13
mveGerry Schmitz6-Apr-19 10:13 
AnswerRe: Get all groups in 4x4 matrix with width and height of power 2 Pin
Daniel Pfeffer6-Apr-19 21:16
professionalDaniel Pfeffer6-Apr-19 21:16 
QuestionTracking Sales and returns. Pin
Member 1420060727-Mar-19 20:22
Member 1420060727-Mar-19 20:22 
QuestionHow to find a good algorithm to fill a dense grid? Pin
Member 141732236-Mar-19 4:36
Member 141732236-Mar-19 4:36 
QuestionHow to calculate the number of labels available on a roll Pin
Member 1409963724-Feb-19 20:10
Member 1409963724-Feb-19 20:10 
GeneralRe: How to calculate the number of labels available on a roll Pin
CHill6024-Feb-19 23:52
mveCHill6024-Feb-19 23:52 
QuestionSteiner tree formulation WITHOUT set of terminals as input Pin
Member 1415897621-Feb-19 21:17
Member 1415897621-Feb-19 21:17 
QuestionNeed an efficient algorithm to solve the following problem Pin
User 1411988416-Feb-19 0:11
User 1411988416-Feb-19 0:11 
AnswerRe: Need an efficient algorithm to solve the following problem Pin
Gerry Schmitz16-Feb-19 8:33
mveGerry Schmitz16-Feb-19 8:33 
QuestionHelp to predict the output of this code Pin
Member 141133789-Jan-19 12:39
Member 141133789-Jan-19 12:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.