Miniature Digital Photo Frame With AI-generated Images

by Northstrix in Circuits > Raspberry Pi

1086 Views, 15 Favorites, 0 Comments

Miniature Digital Photo Frame With AI-generated Images

frnt.jpg

Recently, I discovered the power of Bing Image Creator, a generative AI based on the DALL-E 3 text-to-image model. At first, I was just playing with it and testing its capabilities. However, after exploring it for roughly an hour, I started thinking about its practical applications and where I could use it. Eventually, I realized that I could use it to generate unique images and then display them on the 2.4 Inch TFT LCD with ILI9341 connected to the Raspberry Pi Pico.

If you wish to learn how to do the same, follow along with this tutorial.

Supplies

  • Raspberry Pi Pico x1
  • 2.4 Inch TFT LCD with ILI9341 x1

Ask AI to Generate an Image That You Want

ask_ai_to_gen_pctr.png

To create an image using AI, follow these steps:

  1. Go to bing.com/images/create and enter a description of the image you want the AI to create for you;
  2. Once you have described the image you want, click the "Join & Create" button;
  3. Login to your Microsoft account (If you haven't already). If you don't have a Microsoft account, don't worry, you can create one for free.

Evaluate Generated Images and Generate New Ones

generate_images.png

The Bing Image Creator generates four images at once. If any of them do not meet your expectations, you can try modifying your request or entering an entirely different one. It took me approximately an hour and a half and a couple dozen attempts to get the images I found satisfactory. Take your time here.

Download the Images You Like

downl.png

If you like one of the generated image, click on it and then download it when the button becomes available.

By default, the Miniature Digital Photo Frame With AI-generated Images demonstrated in this tutorial displays four AI-generated images.

Extend the Images

fotor_main.png
fotor_open_img.png
1.png
2.png

It's all great except for one issue: the generated images have a 1:1 aspect ratio, while the 2.4-inch TFT LCD with ILI9341 has an aspect ratio of 16:12. To avoid cutting off important parts of the picture or stretching it, you can use another AI to extend the image.

To extend the image using Fotor AI Image Extender, follow these steps:

  1. Go to fotor.com/features/ai-image-extender/ and click the "Extend Image with AI" button;
  2. On the new page, click the "Open Image" button and navigate to the downloaded image;
  3. The generation process will start after you click the "Generate" button. If you haven't logged into your Fotor account, it will prompt you to do so. If you don't have a Fotor account, don't worry, you can create one for free;
  4. Fotor will generate three versions of an extended image. Choose the one you like, hover a cursor over its thumbnail, and click on the download icon to download it.

Crop and Resize Images

6.png
7.png
done_img.png

In order to display images on the LCD with ILI9341, it is necessary to resize and crop them. You can use any software to perform the resizing and cropping tasks. However, the following instructions are specifically for the Paint.net graphic editor:

  1. Open the image that you wish to resize and crop;
  2. Select the "Rectangle Select" tool from the toolbar on the left-hand side of the screen;
  3. Use the tool to draw a rectangle around the portion of the image that you want to keep;
  4. Once you have the rectangle in place, press "Ctrl+Shift+X" to crop the image;
  5. After cropping the image, it needs to be resized. Click on the "Image" tab in the top menu and select "Resize" from the drop-down menu;
  6. In the "Resize Image" window, set the width to 320 pixels. Ensure that the height of the image is at least 240 pixels. If the height is less than 240 pixels, set it to 240;
  7. Once you have set the new size, click the "OK" button to apply the changes;
  8. Crop the resized image again to make its size 320x240 pixels.

Add a Sacrificial Pixel (line) on the Bottom of Each Image

sacr_px.png

Apparently, that’s the extra work. The reason why you need to do this is that the Image convertor provided in the archive in the next step spoils the bottom pixel (or the line, to be precise) of the bitmap.

Download and Unpack the Archive With Code

dfirmw.png

Download the archive with the firmware for Raspberry Pi Pico and the Image Converter software from SourceForge.

Here's the link for you: https://sourceforge.net/projects/miniature-digital-photo-frame/

Unpack the content of archive to any folder of your choosing after downloading it.

Import the Image Convertor Software to the Eclipse IDE

First and foremost, download and install the Eclipse IDE for Java Developers.

Then, import the Image Convertor to it.

To do so:

  1. Open Eclipse and select "File" from the menu bar;
  2. Click on "Import" and select "General" > "Projects from Folder or Archive;"
  3. Browse to the directory where the Image Convertor is located and select it;
  4. Click the "Finish" button.

Convert Images to the 16-bit Color Array

conv_img.png

To convert an image to a 16-bit color array, follow these steps:

  1. Right-click on the "Image Converter" project;
  2. From the pop-up menu, select "Run As" and then choose "Java Application;"
  3. When the program opens, click on the "Open" button;
  4. Navigate to the 320x241 image that you want to convert;
  5. Click on the "Convert Image" button.

Copy Converted Images to the Sketch for Raspberry Pi Pico

10.png
11.png
12.png

After you have finished converting an image using the Image Converter program, close the application and open the "565_color.txt" file. Next, rename the array to "picture_N," where N corresponds to the image number, and copy the array to the Raspberry Pi Pico firmware. Once you've done that, return to step 9 and repeat the process for the remaining images.

Configure Arduino IDE

If you've never flashed the Raspberry Pi Pico before you need to configure the Arduino IDE first.

Configuring IDE isn't a part of this tutorial. You can read about it here https://www.tomshardware.com/how-to/program-raspberry-pi-pico-with-arduino-ide

Flash Raspberry Pi Pico

13.png

Upload the resulted firmware into the Raspberry Pi Pico.

Assemble the Circuit

RPI_Pico-ILI9341.png

Connect the LCD with ILI9341 to Raspberry Pi Pico.

When it comes to LCD's "BL" pin, different versions of the display have different requirements on what to do with it. Some versions specify that it must be connected to the +3.3V, some require it to be grounded, and others allow you to leave it unconnected.

Enjoy the Result

IMG_20231203_152436.jpg

After completing the task, connect the Raspberry Pi Pico to the power source and enjoy the result.

Final Thoughts

_86734d97-9bc9-4acd-a814-36e358c679b4.jpg
_321f47d1-1307-4c3c-95eb-1d1df9602fce.jpg
_e9dd14b7-f291-4afb-a452-17b32eb75479.jpg
_add2a75f-9dcf-4b0e-bbf7-d8d8f1cbfe59.jpg
_72d512ac-becb-4799-956b-24d0ca6123d4.jpg
_9cda3ba0-ac61-429b-ac69-b585cfaed783.jpg
_5500a260-712b-41d0-959a-11d323e4b368.jpg
_a83e4d6b-689f-4ce9-80bc-f4ffbd59b862.jpg
_a736733f-c460-4312-8c85-fb46c524070a.jpg
_19cec29f-1263-4c16-bd17-2f1c2ca836f1.jpg
_bbead3d4-c1e1-4428-8b6c-66ab45f87293.jpg
_b192c94b-c6a4-499a-9871-1a2afb135c02.jpg
_4a332c95-1a66-440e-aa86-6dfcebb482b0.jpg
_624471d8-5ca8-4dc5-9454-ec8cfac61b6b.jpg
_f0d2e62c-e19a-4b28-8a7f-bdf4fe8b70bc.jpg
_16bddc9e-108b-4783-8232-2efa1e54e904.jpg

Bing Image Creator is an amazing tool that enables you to channel your imagination and unleash your creative potential. I utilized this tool to generate images for a miniature digital photo frame and found it especially convenient for generating pixel art images.

You may also be able to find an area where you can benefit from using this and other AI-based tools. It's all up to you.


By the way, here are more images that Bing Image Creator generated at my request.


Content credentials:

All images demonstrated in this tutorial were generated with AI on December 1 and December 2, 2023


If you found this tutorial to be useful, please consider sharing it.

Thank you for reading this tutorial.