Author Topic: Image processing library  (Read 1267 times)

0 Members and 1 Guest are viewing this topic.

Offline RhoSigma

  • Seasoned Forum Regular
  • Posts: 456
  • GT v0.13 [sr]
Image processing library
« on: January 16, 2019, 08:56:48 AM »
This is another small library of mine, which was lost with the old [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] forum. Since then the library got a complete revision, adding support for using mask images to determine the image areas to process. This is completly optional, so if you want to process the entire image, then simply specify an invalid handle (-1) for the mask parameter. Also still available is the processing area selection by min/max pixel coordinates.

EDIT:
Download attachement removed ...
This library is now part of my libraries collection, which you can download from the bonus stuff section here:
https://www.qb64.org/forum/index.php?topic=809.msg100182#msg100182
« Last Edit: June 11, 2019, 12:55:47 PM by RhoSigma »
My Projects:   https://www.qb64.org/forum/index.php?topic=809
GuiTools - Another graphic UI framework, supports multiple UI forms/windows in one program.
Libraries - Image processing/Data buffering/MD5/SHA2/LZW etc.
Bonus - Screen Blankers, QB64/Notepad++ setup pack

Offline bplus

  • Forum Resident
  • Posts: 6843
  • b = b + ...
Re: Image processing library
« Reply #1 on: January 17, 2019, 02:18:53 PM »
Thanks RhoSigma

This is a nice set of routines and the demo is not bad either specially for this time of year.

Have you ever tried converting an image to B&W ASCII characters?

Offline RhoSigma

  • Seasoned Forum Regular
  • Posts: 456
  • GT v0.13 [sr]
Re: Image processing library
« Reply #2 on: January 18, 2019, 04:10:19 AM »
Have you ever tried converting an image to B&W ASCII characters?

I've an idea how to do that easily, but not yet made any progress in code.

The idea is to give a string containing 2-16 chars representing the desired graylevels ascending from black(0) to white(255) (eg. " .:-=+oO80@#"), and also give the desired width of the ascii art in chars (eg. 120) as well as the desired font height (eg. 8). Now dividing the image in blocks according to the given charwidth/fontheight and then calculate the graylevel of each block by grayscaling each of its pixels and building the average of all pixels in a block, which will result in regular gray values from 0-255. According to the calculated graylevel the respective char will be chosen from the given string.
« Last Edit: January 22, 2019, 04:02:40 AM by RhoSigma »
My Projects:   https://www.qb64.org/forum/index.php?topic=809
GuiTools - Another graphic UI framework, supports multiple UI forms/windows in one program.
Libraries - Image processing/Data buffering/MD5/SHA2/LZW etc.
Bonus - Screen Blankers, QB64/Notepad++ setup pack

Offline RhoSigma

  • Seasoned Forum Regular
  • Posts: 456
  • GT v0.13 [sr]
Re: Image processing library
« Reply #3 on: January 18, 2019, 03:53:14 PM »
Hi all,
here is a prototype of the ASCII-Art function as I did describe it in the previous post. There are certainly many things which can be improved on the function, but as I don't need those stuff, I will not further develop it. Just made it to transform my idea into some real code, but further improvement I'll leave on the SCREEN 0 maniacs. Or maybe Steve is willing to make "The Overengineered 'ASCII-Art' FUNCTION." :)

EDIT:
Codebox removed ...
The function is available as example program for the Image processing library, which is part of my libraries collection.
You can download the collection from the bonus stuff section here:
https://www.qb64.org/forum/index.php?topic=809.msg100182#msg100182
« Last Edit: June 11, 2019, 12:56:51 PM by RhoSigma »
My Projects:   https://www.qb64.org/forum/index.php?topic=809
GuiTools - Another graphic UI framework, supports multiple UI forms/windows in one program.
Libraries - Image processing/Data buffering/MD5/SHA2/LZW etc.
Bonus - Screen Blankers, QB64/Notepad++ setup pack

Offline bplus

  • Forum Resident
  • Posts: 6843
  • b = b + ...
Re: Image processing library
« Reply #4 on: January 19, 2019, 11:16:23 AM »
That is excellent! Thanks  :)

Offline Donald Foster

  • Newbie
  • Posts: 53
Re: Image processing library
« Reply #5 on: January 19, 2019, 04:02:37 PM »
Hello,

I downloaded it in my QB64 main folder, but could not find the ImgProcDemo.bas file. These kind of problems always happen to me when I try downloading stuff like this with multiple files. What a I doing wrong? Nobody else seems to have this problem.

Donald

Offline bplus

  • Forum Resident
  • Posts: 6843
  • b = b + ...
Re: Image processing library
« Reply #6 on: January 19, 2019, 04:18:17 PM »
It will work for any image just change filename for image (use standard image formats).

I am referring to the second code snippet, which works independently of the first code set RhoSigma packed up.

« Last Edit: January 19, 2019, 04:28:17 PM by bplus »

Offline bplus

  • Forum Resident
  • Posts: 6843
  • b = b + ...
Re: Image processing library
« Reply #7 on: January 19, 2019, 04:31:42 PM »
Hello,

I downloaded it in my QB64 main folder, but could not find the ImgProcDemo.bas file. These kind of problems always happen to me when I try downloading stuff like this with multiple files. What a I doing wrong? Nobody else seems to have this problem.

Donald

You could not find that file after you extracted from the .7z file? Where did you extract to? It should be there.

Offline RhoSigma

  • Seasoned Forum Regular
  • Posts: 456
  • GT v0.13 [sr]
Re: Image processing library
« Reply #8 on: January 20, 2019, 08:31:48 AM »
Hi bplus,
you may have noticed, that the routine does crop the right/bottom parts of the given image, if its pixel width is not evenly divisible by the desired charwidth. I've just updated the codebox above with a fixed routine which always give you a best fit result for every arbitrary image size and desired charwidth.
My Projects:   https://www.qb64.org/forum/index.php?topic=809
GuiTools - Another graphic UI framework, supports multiple UI forms/windows in one program.
Libraries - Image processing/Data buffering/MD5/SHA2/LZW etc.
Bonus - Screen Blankers, QB64/Notepad++ setup pack

Offline bplus

  • Forum Resident
  • Posts: 6843
  • b = b + ...
Re: Image processing library
« Reply #9 on: January 20, 2019, 11:22:36 AM »
Hi RhoSigma,

I did notice something on left edge and wondered if was fitting on right side. My first concern however is the bottom edge, that I can't see, perhaps because of title bar? the window does not fit my screen. Should be no problem working it out for my screen size, you've done all the hard work.

I am toying with idea of expanding the character set after some optimizing experiments ie the best spread of n pixels that form a character... but I suspect you already have the best set for 16 or less characters. For gray levels, you want best symmetric spread of n pixels. I am also toying with idea of trying to match the image cell with the closest character, sort of like image recognition, in order to get closer to a line drawing if possible. So far, this toying has not got me energized enough to start something. I will get going when I get excited about an actual application.