Showing posts with label images. Show all posts
Showing posts with label images. Show all posts

Saturday, September 02, 2023

Automated western art, ABCD test

 kw: experiments, artificial intelligence, simulated intelligence, art, generated art, images, comparisons

Several months ago I had the idea to try more prompts that differed only in the style requested. I ran four sessions with the prompt

Painting of a western landscape with a dramatic sky in the style of [Artist]

The four artists I chose were Albert Bierstadt, Thomas Moran (I was familiar with both), John F Kensett, and R Brownell McGrew (not strictly western, but prolific landscape artists). The initial squares I chose from what Dall-E2 generated for each artist are these:


I outpainted them to these sizes: 3200x1984 (first 2), 1880x1984, and 2944x1920. Resized for composing together, and reduced for this montage, here they are:


The artists are as stated above, beginning at the upper left and proceeding clockwise. With a little study you can see where the original square would be in each image. I cropped large, not quite maximal, portions of each image to a ratio of 16:9, with these results:


For three of these I emphasized the sky, and for the one in Kensett style I emphasized the desert floor, while still leaving plenty of sky.

I hunted through public images by each of these artists so I could show to what extent Dall-E2 emulated him. I searched for paintings that might bear some slight resemblance to the generated ones. This montage is of quite reduced versions of a painting by each artist, clockwise from top right:

  1. Oregon Trail by Bierstadt
  2. Green River, Wyoming by Moran
  3. Mount Chocorua by Kensett
  4. Winter Morning by McGrew


Mt. Chocorua is in Hew Hampshire; JF Kensett is considered a Hudson Valley School painter.

It seems that Dall-E2 can produce distinct styles, but not quite distinctive styles-by-a-particular-artist. Given the millions of high quality images of both photos of wonderful scenery and classic art available online, I don't really need to generate good looking landscapes. This was a fun project, but not something I intend to to a great amount. True (human) artists have little to fear from generated art.

In the future we can expect tools like Dall-E2 to get better and better, and I expect within a year or two the ability to generate highly detailed, 4K images in a single Generate (maybe for a higher price per credit), which can then be edited, including with pasted-in bits one could upload during the process. Will they have a "human touch"?

Why would we want paintings by a nonhuman entity to have a "human touch"? It's the nonhuman touch that interests me. The "Alien City" images I produced earlier are intended to be "not human". Even when I asked for a picture "in the style of Chesley Bonestell" I didn't expect slavish imitation, and I was right about that! The image that resulted is the "least human" of the four.

Thursday, August 31, 2023

Automated abstract art

 kw: experiments, simulated intelligence, art, generated art, images, prompts, abstract paintings

I wanted more pieces of generated art to use for Zoom backgrounds. I happened to see an abstract mural at a restaurant so I took a picture and looked it up. The artist was Lyubov Popova (1889-1924). I downloaded a couple of Popova's pictures and one by Zaza Tuschmalischvili (b. 1960), cropped portions of them, and in three sessions, uploaded each portion to Dall-E2 as a "seed" for some outpainting. The prompt for each session was the same with the exception of the artist's name:

Angular abstract painting in the style of [artist]

Here are the three results.


With the third one, by a living artist, I worked back and forth, eventually erasing nearly all the original seed, so it became more of an inspiration than an integral part. I like all three, though they are rather garish for use as backgrounds. For that purpose I lightened them by adding about 50% brightness to each, with this result:


Depending on the audience, one of these could be an appropriate background. I tried to create abstract paintings without specifying style; here is one of the results, based on the prompt

Abstract painting with vertical grain, melancholy color scheme, low key


The location of the color bar shows that I painted this in vertical orientation, then turned it sideways. Even lightened up, it seems inferior to the ones above, as a background at least.

For the sake of academic meetings or among those who love libraries, I also ran the prompt

A wall of bookshelves filled with books of all colors and many sizes

I outpainted it to two sizes. The smaller one, which is close to HD, I also lightened for use as a background. The larger one (with more shelves) is nearly 4K.


On an HD monitor these all fill the screen. On a larger one, the images with fewer pixels may not do so. This image competes in my affections with the "Big Library" image, shown in this post.

Wednesday, August 30, 2023

Automated art, illustrating Outpainting with DALL-E2

 kw: experiments, simulated intelligence, art, generated art, images, prompts, photo essays

A charity, prospecting for contributions, included some Christmas cards with their appeal. This one really appealed to me. I decided to scan it and upload it to Dall-E2 so I could extend it by Outpainting. In earlier posts on automated art I wrote of Expanding, but Outpainting is the main term used by OpenAI. The original painting is "Holiday Social", copyright Geno Peoples 2017. The artist's website shows this and many other paintings in this "luminous cottage" style and other similar styles (note that the website is not secure).

I tried scanning at various resolutions with descreening, both automated and manual. What worked best was a cell phone photo, manually descreened and reduced in pixel resolution. I suppose I could have downloaded it from the website, where an image 1100x717 is available. If you want one of his paintings big enough to print on canvas you can buy it there. The image above is 1024x763, and is a bit narrower than the original.

When you log into Dall-E2, you can either start with a prompt to generate an image or upload something you want to edit. I prepared this image, and a slightly larger rendition (1450x1080), to experiment with uploading and outpainting. Eventually I ran three outpainting sessions. Grammatical note: In a lengthy discussion like this, I tire of circuitous locutions using the pronoun "one", so I will instead use "you" language.

When you open a Dall-E2 session and upload an image, you have the option to crop it to a square or leave it uncropped. In all cases I skipped cropping. If you crop the image, it is squared up to a size of 1024x1024 pixels or smaller. Every Generate action is done within a Generation Frame of size 1024x1024.

First Session 

I first used the 1450x1080 version, which was loaded at full size when I clicked "Skip cropping". It is necessary to add a prompt before you can click Generate. I began by adding material at all four corners. The image below shows the Edit screen after the first two additions. The buttons at the bottom are, from left to right, Select (for moving the Generation Frame), Scroll (for moving the entire image, Frame and all), Erase, Add Frame (for initiating a Generation Frame), and Upload (which I haven't used. I suspect it lets you add an object to the image but I don't know). The Generate button is above this part of the screen, on the right side. There is a download button next to it, and I use it frequently, keeping in mind the admonition in the gray box at lower left (you may need to click on the image to see it large enough to read that text). Downloaded images are PNG files, about 3-4 times the size of JPG files, but with no compression losses. 

The prompt at this point reads "A holiday visit on a snowy day at sunset in the style of Geno Peoples"; I changed it later.

When you click Generate at any point, you have four choices to choose among. If none is acceptable, you can click Cancel and Generate again (consuming a credit...sigh). After outpainting in all four directions I had this result:

The two extensions in the sky added versions of the sun near sunset, which I didn't like. I combined more outpainting with editing. The next image shows the upper right corner during this process.




The white circle at center right is the eraser. I got rid of the bright bit of sky and an unusual looking window in the tall building. I also removed the sun image at left (not shown in this crop) during the following Generate event.

After getting the sky to my liking, I added material below the two extensions I had made, which yielded the image below, which is now 2560x1728 (the image here is smaller). I can crop a 16:9 portion for my wallpaper folder, any size from 1920x1080 to 2560x1440.



It's notable that the extension of the village to the right in particular adds buildings that are not quite the same style as the original ones. Producing this image consumed 8 credits.

Second Session


I started a new session, uploaded the 1024x763 version and skipped cropping. Here I am about to add material at upper right. You can see that the uploaded image is smaller than a Generation Frame. I was hoping to produce a larger village, relative to the initial painting.

I wonder if I should have outpainted in smaller increments, such as having the Frame begin at the base of the large house. I did some Cancels this time. Buildings being added were often in a clashing style. Midway through the process I appended the words "finely detailed" to the prompt. It made little difference. Here we see the result after four corners were extended:


This image needs some work. As the next image shows, I did a lot of erasing while further extending. I ignored the added Moon; I plan to crop it out of a 16:9 image later.


Erasing while outpainting produced an image I like a bit better, shown next, but I like it less than the final image from the first session. 


This image (here it is reduced) is 2304 x 1792. I can crop out anything from 1920x1080 to 2304x1296 if I decide to use it as wallpaper. Producing it consumed 10 credits. Not as much bang for the buck as usual.

Third Session

I decided to try again with the 1024x763 version. Before outpainting I entered a different prompt: An old-time village in winter just after sunset with meltwater on snowy roads, in luminous cottage style

This time I extended downward first, to fill a 1024x1024 square, then I extended to the right and the left, with one Cancel, to get this:


This is 2240x1024. The added material is a bit cruder than the original painting, so I won't outpaint further. Rather, to produce a wallpaper image I'll increase the resolution (I use IrfanView, but Photoshop and Gimp are also good) to 2362x1080. I may use Unsharp Masking to boost the apparent sharpness a little. Then I can crop out a 1920x1080 piece, probably more to the left to include less of the reddish buildings. In the prompt I didn't refer to Geno Peoples, but used a more generic style note. I am not sure to what extent it helped. This image consumed 4 credits. I like it better than the one from Session 2.

Dall-E2 is an enjoyable collaborator, very useful but sometimes recalcitrant. It keeps things interesting.

Tuesday, August 29, 2023

Automated art, landscapes and beaches

 kw: experiments, artificial intelligence, simulated intelligence, art, generated art, images, prompts

I tried a few prompts to produce landscape paintings, even though both photos and scanned artwork, in large (HD and 4K sizes), abound in Google Images and Yahoo Images. I have downloaded many such images into folders that are used by a "screen saver" slideshow program when my computer is idle. Anyway, I thought it worth trying. I first tried Asian art, then more "ordinary" forest scenes, using the following prompts:

  1. A woodcut of a pagoda near a lake in mountainous country colored with pastels
  2. Ink and watercolor, highly detailed, Chinese scroll landscape with pine woods, steep hills, and a river
  3. a calming forest scene with wildflowers in a meadow, a stream, and a small pond, landscape painting
  4. A painting of a meadow in a hardwood forest with a stream and scattered wildflowers, mountains in the distant background


The prompts are clockwise from top left. The pagoda image is rather clumsy. There are two ways that block prints IRL are colorized. Some are printed from a single block with shading and then hand-colored later, and others are printed from multiple blocks with colored inks. This image looks like the latter case. That is to say, multi-block prints were used by Dall-E2 as the "universe" of images to respond to my prompt.

The scroll painting has interesting frame shifts in three places. Near center, what appears as a small waterfall at the base of a dark cliff morphs into a root wrapped on a broken-off tree trunk with growth on its top. At lower right, the scale seems to change, with tiny trees appearing to be far away when viewed in isolation. At upper left, a bit of detached landscape floats in the air. Dall-E2 does such "hallucinations" at times.

The two forested landscapes are both pleasing to me, and I often use one or the other as a background with using Zoom with a green screen. I've found that Dall-E2 "assumes" conifers are meant when "forest" is prompted, unless one specifies "hardwood", or perhaps "deciduous". These hardwoods appear to be birches. If I wanted oaks and maples I'd have had to say so.

I also like beaches, so I tried a couple, with these prompts:

  1. A sandy beach next to a rocky beach below cliffs, digital art
  2. A long stretch of sandy beach backed by sea cliffs, winding towards a distant horizon, digital art


The upper image reminds me of a portion of Pismo Beach, a place I stayed a couple of times several decades ago. The lower one came out like an aerial photo or drone shot. The shape of the bluffs is reminiscent more of a semi-tropical area such as New Zealand (sadly, known to me only through photos). I could have erased the sand bars at lower right and had Dall-E2 put in more water, but they do add a little interest. My favorite body-surfing beaches, near Huntington Beach south of Los Angeles and Sunset Beach to the north, have sand bars at low tide, which at high tide generate large, fast breakers that are a thrill to ride, but not popular with surfboarders.

Wednesday, August 16, 2023

Adventures with automated art

 kw: experiments, artificial intelligence, simulated intelligence, art, generated art, images

Do you desire to make art, but can't draw? I'm like that. My father painted as a hobby for much of his life, and my house and my brothers' houses contain numbers of his paintings; he also sold a few and gave away even more. One of my brothers got all the art talent, and I got very little. I learned of prompted art generation almost a year ago, and last November I decided to give it a try.

I tried out all three major art-generation sites, DALL-E2, MidJourney, and Stable Diffusion. My early take on these is posted here. Since that time I've used DALL-E2. A quick intro:

  • When you start you get 50 free credits. Another 15 free credits arrive each month thereafter.
  • Added credits can be purchased at the rate of 115 for $15. I find that I buy more credits about every second or third month.
  • To start, after setting up an account and logging in, there is a space to enter a prompt. You'll use many of your first 50 credits getting used to writing prompts. There are tons of YouTube videos where you can get creative and useful ideas.
  • You can also upload an image you want to edit. I won't get into that.
  • When you click Generate, you get a panel of four square images. Their size is 1024x1024 (in the earlier version of DALL-E they were 512x512).
  • You can click on one of the four squares to see it larger, and download it as a PNG file; its size will be 1.5-2 Mbytes.
  • When looking at one of the squares you can click Edit. The two main options here are Erase and Extend (called Add a Generation Frame). You can also upload an image at this point, but I am not sure what happens; I haven't tried it.
    • Use Erase to remove a part of the image you'd like re-rendered differently. Then click Generate and you get 4 versions to look among (a 4-dot clicker to select). You can Accept one of them or Reject and try again.
    • Use Extend to activate a 1024x1024 marquee that you can move around to an overlapping area. Be sure there is some overlap, or you'll get a discordant appendix. Here again you have four versions to select among, to either Reject or to Accept the one you like best.
  • I do tons of Extending, to turn 1024x1024 images into 1920x1080 or larger. I haven't tried going all the way to 4k (3840x2160); that would take at least a dozen Extend tries.
  • Note that each time you click Generate it uses one credit, whether you Accept or Reject the result.

The two images below are the beginnings of a Mountains theme. The prompts that generated the starting squares were

  1. Mountainous Landscape in the style of the Hudson School
  2. A mountain cabin in the style of Thomas Kinkade


These are the first and fifth "paintings" I generated. (You can click on any image for a larger version; this image is a 2-pic pasteup). Each took six or seven Generation events, so each cost less than $1. For the second image I found I had to edit the prompt after a couple of steps, or DALL-E2 would insert more cabins and even whole floating mountains. Prompt editing is a skill in itself. It is part of the "negotiating" one does with DALL-E2 to get the results you want. So is Erasing sections, small or large, and using up more Generate credits.

For my second painting I did a Still Life in the style of Paul Cezanne. Later I did three others. All are shown here, and their prompts, clockwise from top left, were

  1. Still Life with apples, pomegranates, and bananas in the style of Paul Cezanne
  2. A still life painting with cheeses and fruits and a vase in the style of Clara Peeters
  3. A still life painting with peaches, grapes and a vase of flowers, in the style of Raphaelle Peale
  4. A still life painting with a cornish hen, grapes, and leafy greens in the style of Pieter Claesz


For a sense of the scale of extending these images, here is the initial panel from the Paul Cezanne prompt:


This is shown at a roughly similar scale. You can see that I Extended the third square. For all the final paintings, the size was somewhat greater than 1920x1080, and seldom had the 16:9 ratio. Thus I could crop most of a painting to the 16:9 ratio, leaving out the color block DALL-E2 puts at the lower right of all its images.

As I got more experience with DALL-E2, I learned that in addition to asking for styles of a certain artist, one may also specify a genre, such as "painting", "digital art", "pixel art" (blocky), "3D render", "clip art" and others. I'll show examples of some of these in future posts.

Thursday, March 22, 2012

Extracting interest

kw: complexity theory, images, games, analysis

The Shannon Number, Claude Shannon's 1950 estimate of a lower bound on the number of possible games of chess, is 10120. More recent estimates indicate the actual number is at least 10123, or 1,000 times as large. This is interesting, in that there are "only" about 5x1046 possible board positions. Each position has many possible next moves, so the branching at any point is quite dense.

Very, very few of these games are "good" games, meaning they show competent play, though this can be hard to discern. And whether competent or not, very very few are "interesting". For example, there are huge numbers of games that end abruptly with any of several "fools mate" positions, and a comprehensive computer search would no doubt uncover a great number of "total idiot's mate" positions. Then there are those that quickly lead to a stalemate. The number of possible "interesting" games is impossible to determine, but even if only one game in a quadrillion is interesting, that leaves 10108 interesting games. Even the square root of this, 1054, is a number greater than the number of games that will ever be played on Earth, prior to the loss of its oceans to solar heating about a billion years from now.

Around each possibly interesting game, there will be a number, perhaps a large number, of similar games, that differ by a move here or there, or a few moves taken in a different order, but that in the main cover the same ground and lead to the same final position. There will be a larger number of allied games that lead to a similar but not identical final position.

As I thought about this, I realized that such clusters of similar games are analogous to the cluster of similar images one can produce from any given image by manipulating a pixel here or there, or making wholesale, but subtle, changes. However, the number of possible images, even with a small number of pixels, is much greater than the number of chess games.

Consider this image, a 4x expansion of a familiar icon from Microsoft Windows. The format for these icons is 40x40 pixels, and depending on your screen mode, they can have one byte per pixel (256 colors) or three bytes per pixel (16,777,216 colors). Just one byte per pixel produces 2561,600 possible images, with each possible color palette! That is 103,853. The full color version has 1011,559 possible images. For this image, as for any other, changing the color of any particular pixel by a small amount has no visual effect. Although a computer vision system could immediately tell the difference, the human eye/brain cannot.

Even wholesale changes to the image, such as this shift to a lower gamma, are difficult to discern unless the two images are right next to one another. Let's consider a situation in which we watermark an image by adding one to certain pixel values, leaving the rest unchanged. There are 21,600, or 1.16x1077, possible single bit-level changes in a 40x40 pixel image. If we allow adding 1, 2, or 3 to the low order bits of an arbitrary number of pixels, the number of possible changes for this two-bit-level watermark is the square of the first number, or 1.34x10154, which is 13 quadrillion quadrillion times Shannon's Number. That is the number of effectively undetectable changes to an icon image that could be made. Actually, as other kinds of changes can be made, without visually detectable effect, the cluster of similar images about any given image is much, much larger.

We can try to extract what it is that makes the image
"interesting" by reducing the original image to a 2-level (1-bit) representation. It would take some tinkering to change this image so it looks more like the original, having complete outlines around the pages, for example. So even here, there is a cluster of variations on the theme.

The number of such 1-bit images is the same as the number of single-bit-level watermarks, about 1077, and we can easily see that not all of those will be equally interesting. No matter. There is enough available complexity out there for us to keep devising new icons for the next billion years, without having examined more than a tiny fraction of the possible image space.

There is a lot of world out there. Given the level of complexity available just in a chess game on a board of 64 squares, or in a picture 40 pixels on a side, it is a wonder that anything ever repeats!

Saturday, January 24, 2009

More art of grief

kw: images, memorials

I was taking a shortcut through northernmost Delaware when I happened on a couple of roadside memorials. I've commented on these before, here. These two are some of the newer ones I've encountered.

Though these memorials are motivated by tragic circumstances, I look on them as examples of folk art by people who do not think of themselves as artists. On this one, the name Cliff can just barely be made out, though the memorial is only two years old. This has the look of being primarily the work of Cliff's children. The setting is intimate, a small, boulder-strewn valley at a tight bend in the road. Fortunately, there is a straight run on both approaches to the bend, and little traffic, so I could get close to the memorial without risking becoming the next victim.

This memorial is on a straight stretch of road. I surmise that the late Pieter fell asleep. Looking away from the road, however, the scene is rather desolate. This meadow is part of a wildlife refuge. I understand that developers want to turn the lands east of the refuge into some kind of mixed mall-plus-residential venture. Most of the non-refuge land is a cornfield. To me, that is already its best use.

I'll forbear to rant, just noting that, if I were king, I'd make it a capital offense to develop land that can grow food. We may not need that much food today, but in the future, we most certainly will.

Back to memorials. Most are as simple as this cross, though few are as well carved. A quick search on Google images for "roadside memorials" yields quite a variety. There are hundreds, perhaps a thousand, recorded among the 5,000+ hits that the search returns.

Friday, March 21, 2008

The art of grief

kw: images, memorials

The day after my return from California, I reported on the most memorable sight of the trip, the Watts Towers. Just a few days earlier, in the Mojave Desert, I had seen a piece of folk art that is quite a bit more modest.

We've all seen little crosses—and more elaborate displays—beside the road, commemorating a spot where someone died in a collision. This one is right at the Lavic overpass, where old Route 66 (now National Trails Highway in that area) crosses over US 40. That is a perfect spot for an accident, because the left turn is as sharp as road-building technology can make it. Of course, the roadbed is rough enough that it is hard to travel at a dangerous speed.

This little cross, about three feet high, is apparently of found material, but it is the decoration that interests me. There is no name that I can see; it is a memorial understood only by the maker. But he or she was prompted to add a spray of plastic flowers. Perhaps the unadorned cross was just too stark.

These expressions of love and grief interest me as abundant examples of folk art. Though most are erected very quickly, they are often very beautiful. They seem to hark back to the beginnings of funerary art, before we all began to pay professionals to produce granite or marble memorials for grave sites. With this little cross in Lavic, I decided to photograph any that I see, particularly now that many states have begun to remove them. Here I will show just a couple of others, from my local area.

At the intersection of US 202 and Silverside Road in Talleyville, Delaware, this is about as simple as they come. It is hard to get in a position for a good photograph. Both roads are very busy, and this is on a median right below the traffic signal.

I've seen it there for more than ten years. It is barely possible to make out the date, 12/13/1997.

I used a long lens from a nearby parking lot. It wasn't easy even to get to a parking lot on the median, across a feeder. This is one aspect of these memorials: Putting them up, or getting to the place you want to put them, is often risky. I can think of two I'd like to photograph, but it will require stopping on the wrong side of a feeder or freeway ramp to do so.

Crosses are the most common motif of roadside memorials. Enter "roadside memorial" in a Google Images search box, and you'll see what I mean. This montage is taken from the first two pages of returns. The second item is a Russian Orthodox cross. I suspect there are also Celtic crosses out there.

Of course, only Christians and the nonreligious who are sympathetic to Christian imagery use crosses. I have yet to see a Jewish or Hindu motif, but I'll snap one if I see it.

Christian or not, many memorials do not use crosses, though nearly all use flowers. This one appeared near the driveway into Brandywine High School three years ago.

Some memorials use hearts, some use pictures, and one in this montage uses a surfboard. The elements are meaningful to the maker, and usually to the victim. What is most distinctive, however, is that unlike most folk art, they are intended for display, and are placed at a meaningful location rather than in one's home (though I expect that many memorializers have a shrine to the victim in the home also, for at least some period of time).

I had thought to make a significant effort to collect images of these ephemeral pieces of folk art. They'd make a good subject for a book. As it turns out...

Holly Everett has written such a book, which is published by Texas A&M U. I should have known. It is too good a subject to remain unpublished this late. Though in her title Ms Everett mentions only Crosses, she discusses memorials of all kinds. You may consider this a pre-review of the book. I suspect it'll show up where I can get it before long.

Meantime, I'll continue to photograph these roadside memorials wherever I find them. Note that only the three larger images in this post are mine. The two montages were pasted together from images found on the web, and the book cover is from the TAMU web site linked above.

Saturday, February 23, 2008

A Descreening follow-up

kw: instructions, images, tools

Trust a spate of writing to get the juices flowing! After writing the prior post, I tinkered around a bit with the scanner. I found some better settings and procedures.

Most scanners have a Twain or similar driver screen, and an Advanced mode, where you'll find color tuning and various filtering operations such as Unsharp Masking, often including Descreening. Preview runs fast, so I could pre-outline the area to scan (my older scanner did this more "up front", it took until today to find it in the new one). After setting the area desired, Zoom lets you refine it if needed (an example appears later).

I Previewed the image of the girl and her dogs and Selected just that area, set 150 dpi for final output, and then clicked Descreen and Scan.


First, these clips illustrate the differences between the automatic method and my multi-step "hand" method (you can jump down and skim the prior article—or click here if you're viewing single posts; use Back to return—to get familiar with the method).

The clips, as before, have the corner of the girl's mouth at the upper right. The 30x30 shown here is the result of Auto-Descreening, and the 120x120 is a 4x resize to see the pixels. The two clips below it show the result of my 5- or 6-step method, which begins with a scan, unfiltered, at 600 dpi. The result of either method is an image with 150 dpi resolution, and the halftone dots and their Moiré pattern removed.

The unsharpened version is closest to the Auto result, but a little inferior. The sharpened version has more visual interest for me, but take a look at the white dot in the lower-right clip, on the girl's neck near the collar. That may be real, but he faint ring around it is a sharpening artifact. To my judgment, the Auto process gave slightly better results.

This is the full image of the picture from the book. It is very nearly the same physical size on my screen as the picture in the book (its size on your monitor will depend on its own dpi). Click on the image to see all that its 150 dpi resolution can show. Blogger limits images to about 400 dots vertically, and the 150 dpi image is 752 dots tall. It will slightly overfill the browser window (or the left half of it) on a 1024x768 screen.

This points up a practical matter. No matter how nice your original image is, if you are going to use it in a blog be sure it looks "pretty good" at that size. I once had a graphic with lots of details, and the lines were so thin, they mostly vanished. I had to redraft it and simplify it. It just wouldn't do to say, "Click on this critter to see it better...sorry for the mess you see right now".

So, after all the Sturm und Drang, I've obtained as good a copy of the book's photo as technology (that I can afford) currently allows. I decided to try a full-color picture from a magazine. I needed something small...


I happened to have a recent issue of AARP The Magazine around, and saw an article by Dr. Andrew Weil, with his image in the byline. This is the Preview/Zoom screen view of an early stage in capturing a picture of Dr. Weil. A small (¾ x 1 inch) face-photo accompanies his articles in many venues. The halftone dots are quite clear, particularly around the eyes.

This image is about what you'd see in a raw 300 dpi scan. The larger one that a click will reveal is close to 360 dpi. This is a screen capture image, and its resolution depends on the way the scanner driver runs its Zoom routine.

I had two ways I could proceed. I first used the Auto-Descreen from the scanner, then I loaded the screen capture image and, without any blurring at all, resized it to 0.24 to match the 150 dpi image (it has a boundary the other image doesn't have.) I used the Lanczos filter for resizing, the slowest and best filter offered in IrfanView.

The small image on the left is the Auto-Descreened result. It is very good. The other is the shrunken screen capture shot. There is a bit more background noise, but to a quick glance, the images are very similar in quality.

I reckon I'll keep fooling around with hand descreening, but I've determined the Twain driver does a fine job, and I'm switching to it for production.

Friday, February 22, 2008

Descreening with IrfanView

kw: instructions, images, tools

OK, if you like to edit digital photos, then before you go any further, go to /www.irfanview.com/ and download IrfanView. I use it almost daily.

A book I'll soon review contains mostly photos. In the past, I've used scanned photos in the blog, and I did a lot of work on them for viewing on the computer. My scanner has a "descreen" option, but I found I could use a few steps in IrfanView and get a better result. The following procedure is to completely descreen an image scanned from a halftone print. The example image is a 2-tone Sepia-toned reproduction of an old photo, but the method is the same for monotone or full color.

Halftone on glossy pages such as a magazine or photo-oriented book has from one to four (sometimes seven) hexagonal dot patterns with a pitch of 120 to 180 dots per inch; 150 dpi is most common at present. Halftone on newspaper pages and other non-shiny paper has a pitch of 80 to 120 dpi; 100 dpi is most common. There is a whole discipline of picking the angles for the different screens so they won't produce unsightly Moiré patterns (interference banding). So it makes no sense to try for a final image with more than 100 or 150 dots per inch.

To descreen, one must begin with lots of resolution; much of it will be discarded in stages, but it is needed at first. I scan at 600 dpi. This seemingly large image is a 1.33x1.75 inch clip from a larger image on the book's page. At 600 dpi, full size is 797x1039 pixels.

This 120x120 clip from the image, with a corner of the girl's mouth at upper right, shows the halftone pattern well. If you click on the larger image, you'll see the pattern over the whole image when it is shown at full size. The "circly" pattern is a very small moiré pattern of the black and brown screens overlaid at an angle (I think it is 37°). This amount of interference cannot be avoided.

Of course, the "proper" way to descreen such an image is to use Fourier series filtering. It doesn't simply remove all frequencies higher than, say, 80 dpi; it removes the specific frequencies that pertain to the screen patterns, leaving some extra photo detail visible. It is thus better than both the descreen routine in my scanner and this procedure, but for most purposes our process will be sufficient. Those with the extra energy can get Fourier analysis software...it doesn't come cheap or easy.

The first step is to do a basic, full blur. In IrfanView I enter Ctrl+E (Menu Image/Effects/Effects browser...), select the Blur item and set the amount to 99. This causes complete mixing within a 1-pixel range. If you look carefully at this image, it has a smoother look.

This 120x120 clip shows that it is indeed smoother, the photo details look good, but some halftone remains.

For many purposes you can reduce this image to ¼ size so it is displayed at 150 dpi (or 50% larger than "life" on a 100 dpi monitor and 2x on a 75 dpi older monitor). In IrfanView, Ctrl+R (Menu Image/Resize) selects Resize where you can single-click a half-size reduction or enter any percent (use 25% for quarter size). Also, I use the slowest resize filter for best results; there are several in a panel on the Resize dialog.

However, I like a little better final results with no halftone remaining, so I blur twice more. Once at this size and once at an intermediate size.

This image results from repeating the Blur step.

This 120x120 clip shows that some remnant of halftone patterning remains. This is better removed by resizing and blurring again.

Some day I'll take the time to run a few pix through this process, then do it again skipping this blur step, to see how it impacts the final image.

A test image that I took using the scanner's Descreen option looked rather good at the outset (the scanner delivered a 300 dpi image). I blurred it once, reduced by half for 150 dpi, and it looked as good as a result from this process. However, to Descreen, the scanner scans in a peculiar version of 1200 dpi, capturing each color separately, so it takes much longer than an "ordinary" 600 dpi scan. I guess I prefer to be "doing something" for the same amount of time, such as fiddling with IrfanView! So, I do more steps.

Though this image is displayed the same size as the ones above, it is half the size "behind the scenes." Click on it and see. The resize averaging makes this look a little better than the prior image already, at this size.

This 60x60 clip covers the same area on the photo as the 120x120 clips above. The halftone patterning is less evident yet, just from the Resize operation.

This is the clip above, resized to 120x120 without smoothing, to show the pixels. Compare it to the clip for the prior photo, the result of two Blur operations. I have to look closely to see remnants of the halftoning.

I encourage you to experiment. I had a little theory to drive me; I knew in a general way what the Blur operation does, for example. It may be that starting with a 300 dpi scan and using fewer Blur steps, perhaps at a % different from 99, will work as well. I am usually in production mode, so I must consciously block out time to experiment or I don't do any.

This is the result of the last Blur operation, done on the half-size image.

A 60x60 clip shows things are a lot smoother, but some irregularities in the girl's complexion seem to have vanished. She may prefer for us to hide signs of acne or moles, but let's wait for the final result.

This is again the small clip resized to 120x120 to show the pixels.

I can see no hint of halftone patterns, not even the Moiré patterning. However, the edges are no longer as sharp as before.

We will be shrinking this image further, to get it to final dimensions and resolution. Remember, our goal is to display at 150 dpi, and this is still at 300 dpi.



This one ought to display at a smaller size than the ones above. This is now ¼ the size of the initial scan.

A 30x30 clip shows we have a pretty sharp image now, for this resolution, with no sign of the original halftone.

This 120x120 blowup of the tiny clip above shows the pixels. You can see that the edges are just two pixels across.

Many times, you can stop right here. At the risk of resurrecting some sign of the screens, I like to do a final sharpening step. Most of the time, I like the result better.

In the Effects Browser you can set the amount of Sharpening to do. I usually set it at 20%. Irfanview does a full sharpening (100%), which you can try to see how blocky it looks. But when you add 20% of that to 80% of the original image, it looks pretty good. This is my final, production image. Overall, there is a somewhat grainy look that makes this more like a photo than a halftone print.

The 30x30 clip is now displayed at the same resolution as the larger image. The total image has plenty of snap and interest. And let's remember that this started as a stamp-sized snip from a 3½x5 inch image.

This blowup of the 30x30 to 120x120 shows that the apparent width of edges is closer to a single pixel, as would be the case if we'd scanned at 150 dpi an original photo that had hundreds of dpi. Because of the halftone image we started with, 150 dpi is actually better than is warranted, but it gives a good combination of "look" and size.

There you have it. Start at 600 dpi, then Blur, Blur, reduce by half, Blur, reduce by half again (to ¼ size), Sharpen, and you're done. It really doesn't take long!