Giter Site home page Giter Site logo

portraits's Introduction

PROCESSING PHOTOS: BOOK PORTRAITS AND MISC PORTRAITS
---–-------------–------------------–-------------–-

As of now, there are two "types" of portraits: ones in my sketchbooks, and
miscellaneous ones. The important difference is that sketchbook portraits
were all scanned at 800dpi on an EPSON photo scanner, while the miscellaneous
portraits are often crappy photos taken on a smart phone that need to be
seriously edited.

Book portraits are, once scanned, first manually rotated (can rotate using
e.g. Finder in MacOS even though it only changes the metadata to include a
rotation, because the script that comes next accounts for that), then the
script process_book_portraits.sh is run, which reduces resolution, filesize,
and color depth; and renames the file and saves a copy of it to the
books/ folder.

Miscellaneous portraits are, first dumped into the folder
misc_portraits_raw/0_photodump (there is a clone of this folder on Google
photos -- all Google Photos albums mentioned have the same name as the
corresponding folder on my computer, in this
case "misc_portraits_raw/0_photodump"). Then, because there are some
duplicates there, a selection of unique portraits is copied to the folder
misc_portraits_raw/1_selection. Next, I upload all the selected photos to
Google Photos. I edit the photos on my phone using SnapSeed, and then save
them to a new album called "misc_portraits_raw/2_edited". Then, I download
the edited photos onto my computer and put them into the
misc_portraits_raw/2_edited folder here. Finally, I use the script called
process_misc_portraits.sh to resize the images, make some edits, and copy
them to the folder misc/.



REDUCING IMAGE SIZE BY LOWERING BIT DEPTH
-----------------------------------------

Colorspaces include: HCL HCLp HSI HSB HSL

DON'T use HSL for testing average saturation on nearly-grayscale images.
It will give spurious results.

See: https://legacy.imagemagick.org/discourse-server/viewtopic.php?t=29781
     https://archive.is/XRNHt

Some test images and their mean saturations:

    convert "book1@800dpi/p 0.png" -resize '1600x1600>' -colors 255 +dither -auto-orient books/tests/testA.png
    convert "book1@800dpi/p 23.png" -resize '1600x1600>' -colors 255 +dither -auto-orient books/tests/testB.png
    convert "book1@800dpi/p 11.png" -resize '1600x1600>' -colors 255 +dither -auto-orient books/tests/testC.png
    convert "book2@800dpi/p 1.png" -resize '1600x1600>' -colors 255 +dither -auto-orient books/tests/testD.png
    convert "book1@800dpi/p 14.png" -resize '1600x1600>' -colors 255 +dither -auto-orient books/tests/testE.png

    convert "books/tests/testA.png" -colorspace HCL -channel g -separate +channel -format "%M: %[fx:mean]\n" info:
    convert "books/tests/testB.png" -colorspace HCL -channel g -separate +channel -format "%M: %[fx:mean]\n" info:
    convert "books/tests/testC.png" -colorspace HCL -channel g -separate +channel -format "%M: %[fx:mean]\n" info:
    convert "books/tests/testD.png" -colorspace HCL -channel g -separate +channel -format "%M: %[fx:mean]\n" info:
    convert "books/tests/testE.png" -colorspace HCL -channel g -separate +channel -format "%M: %[fx:mean]\n" info:

> books/testA.png: 0.0238151
> books/testB.png: 0.050264
> books/testC.png: 0.11977
> books/testD.png: 0.0184644
> books/testE.png: 0.223645

This prints the average saturation ("colorfulness") of each image. The two
more colorful images (testC.png and testE.png) give significantly higher
numbers than the more grayscale-like images. An interesting case is
testB.png, which is drawn in red colored pencil. The average saturation is an
in-between number. For the purposes of reducing image size by lowering bit
depth, it seems like putting a threshold at around 0.08 is appropriate.
(Meaning, I will reduce bit depth on images whose average saturation is less
than 0.08, but not on those whose average saturation is higher than 0.08.)

In the actual script that edits the images, combining the two commands above
into one doesn't seem to work, so I had to pipe them:

    convert "book1@800dpi/p 0.png" -alpha off -resize '20x20>' png:- | \
        convert - -colorspace HCL -channel g -separate +channel -format "%[fx:mean]\n" info:

portraits's People

Contributors

rothos avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.