skip to Main Content

I’m experiencing interpolation issues as you can see in the images when converting a high-resolution PNG logo image to a .C array for display on a Duinotech SSD1351 XC3726 128 x 128 OLED display connected to an Arduino Uno.

What are the best practices to do this without introducing noticeable interpolation artifacts?

logo

.C output to display with issues

I tried repeating the steps multiple times.

I tried different basic image resizing SASS products such as Gimp and Photopea but not photoshop then done the code conversion in the image converter of rinkydinkelectronics.com
I have made sure that I have all the correct and functional libraries requires in Arduino and that my Macbook pro isn’t optimising programme files to the cloud due to low memory space.

I did find some code line in git hub to do this (In processing) and it appeared to give me code but the image was too large. May try this again.

2

Answers


  1. Judging by the image, I’d say you’re either saving or parsing the image at the wrong resolution. You could try playing with the way it’s rendered a bit or verifying the input and output settings from both sides.

    Login or Signup to reply.
  2. You don’t have interpolation artifacts. You have one or more of:

    1. Your width/stride is incorrect.
    2. You’re accessing the pixel incorrectly (e.g.). It’s three bytes / pixel for RGB data and you’re accessing it as a single [monochrome] byte (or vice versa).

    You can use ImageMagick’s convert program:

    # resize original JPEG to 128x128
    convert orig.jpg -geometry 128x128 small.jpg
    
    # convert image to P6 (binary) .ppm format
    convert small.jpg small.ppm
    
    # convert .ppm to P3 (ascii) format
    convert small.ppm -compress none final.ppm
    

    The above will yield final.ppm. The top part looks like:

    P3
    128 128
    255
    255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 253 254 255 253 254 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 254 251 255 255 251 255 255 255 254 255 255 254 255 255 254 255 255 254 255 255 253 255 254 253 255 254 253 255 254 253 253 253 253 253 253 253 253 253 253 253 253 253 253 255 253 253 255 253 253 255 252 253 255 253 255 254 251 255 254 253 255 254 252 254 253 252 254 253 251 253 252 252 252 254 252 252 254 252 252 254 252 252 254 251 252 255 251 252 255 249 253 255 249 253 255 248 253 255 248 253 255 249 254 255 249 254 255 250 254 255 250 254 255 252 253 255 252 253 255 253 253 255 253 253 255 252 252 254 252 252 254 251 253 252 251 253 252 251 253 252 251 253 252 249 253 252 249 253 252 253 253 255 253 253 255 253 253 255 253 253 255 253 253 253 253 253 253 253 253 253 253 253 253 254 255 255 254 255 255 254 255 255 254 255 255 254 255 255 254 255 255 254 255 255 255 255 253 255 255 253 255 254 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 255 255 251 254 255 251 254 255 251 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
    

    You can strip off the first three lines and [easily] convert this to an initializer list (with commas) that you put into a .h file.

    Remember it’s R/G/B, so there are three numbers per pixel.

    unsigned char logo[128][128][3] = {
    // data with commas
    };
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search