Having scanned the lion kingdom's entire collection of printed music, it was time to ponder how to read it all on the reader. The mane problem is the contrast is not as good as IMSLP downloads. The simple threshold algorithm would never be automatic enough to compress the thousands of pages. An edge detection algorithm slightly improves the contrast, but still needs too much fussing. The easiest solution is to get the reader to support greyscale.
The algorithm of the last 4 years stored bitmap only, 1 byte for every 3 pixels, 1 bit for each pixel. The new algorithm needs to write the direct frame buffer values.
The if(value > threshold) in pdftoreader2.c would need to get smarter. dst_row[col] would have to be a 16 bit destination. Component would have to be replaced with a 565 color channel value scaled by the current pixel. The config file needs an option to enable greyscale mode.
Cropping would have to go back to being manual. It would be hard to read.
Should be noted the annotations have 1 pixel for every 3 of the score pixels. The conversion from 1 bit to 1 pixel is replicated in many places.

A test file for greyscale emerged.

Magnifying showed it was using 1 component for each pixel.

A greyscale music scan was harder to read because of the lack of contrast, but it resolved a lot more detail than a 1 bit scan. Automatic cropping with an automatic histogram normalizing the dynamic range seemed to do the job.

It was using each component as a pixel.

The improvement in detail is a lot more obvious with scanned text.


If we rescan some IMSLP files in greyscale, the files get 5x bigger & 5x slower to load, but the page turns don't get dramatically slower.

The IMSLP files are 1 bit, but the reader program averages the pixels when it's in greyscale mode. The reader program takes the darkest pixel in 1 bit mode. Many combinations of THRESHOLD values & pixel averaging algorithms could try to improve the quality of 1 bit mode. The THRESHOLD value is only used for cropping in greyscale mode. Whether or not to switch everything to greyscale depends on the wait time when loading. 1 bit mode hasn't been problematic for reading most music. Its only problem area was resolving the Liszt sonata in B minor, but lions would have found it difficult to wait for it to load 33 pages.
lion mclionhead
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.