Page 2 of 2

Re: Best Unsharp Mask settings after resizing photos

Posted: 2014-10-26T19:11:54-07:00
by rossdv8
Thanks snibgo. Sadly none of that was much use for finding out how to actually use miff. So I searched inside this forum and also searched google to try to find some description of how to work with miff.

Sadly, again, there seems to be nothing written anywhere about what it does, how it can be used. Only technical stuff about how it stores things and some stuff that makes no sense to someone who just wants to write a simple script to get a job done.

And using the extension .miff in my script locked up my computer for a whole night with the hard drive running.

So, this morning I converted a file to miff and opened the file to try to understand it. Then I converted ten files and tried different uses of the .miff extension.

That led to the discovery that a single .miff can contain all the exif information stored not only in an image, but as you told me, in a collection of images.

Which led to reasoning that I should direct a convert command not to something like *.miff, but to something like working-file.miff

That led me to try performing an operation on a single image .miff and converting it back to a viewable format. So I tried converting a multi image .miff and setting a $file.jpg type output.

And there was the result. the .miff spat out each file that had been stored inside it, as single jpeg files, processed and renamed and in an output folder, just as I wanted them.

Now, the big question. Why is there not some sort of simple description of this process, or even a simple tutorial about how someone can use the .miff to achieve 'stuff'?

On another point, especially if the Original Poster decides to poke around in this thread again, the more or less 'generic' settings I am using are working on everything from high resolution images down to 100kb thumbnails, but work best on stuff over 500kb. Those settings are even working well on 3D text generated by IM convert command.

This I think was what the OP was asking about. Because there is really no 'best' settign for unsharp, I believe like me he was looking for something more or less generic to get an improvement across a batch of files.

What his question did for me though, was saved me about $1000 that I was going to spend on an SLR digital camera. Because all my long distance zoom shots are now allowing me to see detail over a distance of several nautical miles at 12x zoom.

So once again IM comes to the rescue and I've learned a heap more about my cameras.
Next step is to incorporate my HALD-CLUT enhancements somewhere before the unsharp command
Here's how the script looks so far using .miff in the middle. And you are right - it does seem to cut the processing time, but I will have to do timed tests to see just how much. I'm using an old E-350 processor at only 1.6Ghz and 4GB RAM, so nothing happens quickly.

Code: Select all

!#/bin/bash
# RossDV8's unsharp script for ImageMagick under Linux
# This strips the profile from every jpeg in a folder then applies basic unsharp
#  NOTE - DO This ONLY after all other corrections including HALD CLUT have been done

# RENAME all JPG to jpg
      #!/bin/sh
      # lowerit-this bit is scrounged off the net - but it works well
      # convert all file names in the current directory to lower case
      # only operates on plain files--does not change the name of directories
      # will ask for verification before overwriting an existing file
      for x in `ls`
        do
        if [ ! -f $x ]; then
          continue
          fi
        lc=`echo $x  | tr '[A-Z]' '[a-z]'`
        if [ $lc != $x ]; then
          mv  $x $lc
        fi
        done

#From here it is basically IM 
# Strip ICC profiles and store in a miff file   
convert *.jpg +profile "*" noicc.miff

# Apply unsharp mask to all jpegs in the miff then convert them back to jpegs
convert noicc.miff  -unsharp 10x4+1+0 'unsharp'$file.jpg

# Make output folder
mkdir UnSharped

# move unsharped files to output
mv unsharp* UnSharped

# Clean Up
rm noicc*

Re: Best Unsharp Mask settings after resizing photos

Posted: 2014-10-26T20:10:00-07:00
by snibgo
You may not realise that your convert commands read all of your images into memory, then process each one, then write them out. This is fine if you have small images, or not many images, or loads of memory. An alternative scheme is to process each file one by one, so each convert command reads, processes and writes only one image at a time.


The two convert commands:

Code: Select all

convert *.jpg +profile "*" noicc.miff
convert noicc.miff  -unsharp 10x4+1+0 'unsharp'$file.jpg
... can be combined into one:

Code: Select all

convert *.jpg +profile "*" -unsharp 10x4+1+0 'unsharp'$file.jpg

Miff is just another file format for storing raster images. Like tiff, it can store multiple images. For most functional purposes, tiff and miff are interchangeable. They can be used in the same way. But miff is private to IM; other image viewers can't read it. It is useful for storing temporary results, or to improve the speed of a script that needs to read an image multiple times: I convert the input image to a miff, then reading the miff multiple times is usually much faster than reading the original input. Mpc format may or may not be even faster.

My rule of thumb about jpegs: I never use them unless I have to. I never use them for intermedite results (exception: rough-cut video editing).

On my to-do list is a page about file formats, strengths and weaknesses of each, and when to use what. Sadly the to-do list keeps growing.

Re: Best Unsharp Mask settings after resizing photos

Posted: 2014-10-27T06:53:24-07:00
by rossdv8
Thank you snibgo.
That explanation tells me more than anything I've been able to find so far, except my using your earlier 'hints' and a lot of trial and error.
I wondered why my attempts to run multiple processes inside the miff were not working, yet there can be a heap of images actually in there.

I think you've seen results of some of my scripts posted in other topics. Like the Diagrid script. This unsharp script was written simply to show anyone looking for a more or less generic unsharp setting, that it is possible with reasonable results.

For all my actual work my very first conversion after renaming to lower case, converts everything to png. That results in some huge files, but I'm usually applying a HALD table to them thanks to Fred, Anthony and you, in order to get the adjustments I would usually do in GIMP.

But I was still annoyed by the results of my camera. I had messed with unsharp in GIMP and it was in the back of my mind when I read this thread. So I applied the basic settings I use in GIMP and that someone else had mentioned here and suddenly all my photos and end result graphics were almost 3D.

But I can see from what you say, that like HALD-CLUT, there might be something exciting in this miff format as far as the processing sequence goes. if I can ever fathom it out. You'll know from previous posts that I had a brain infection and my thought processes now relegate me to simple scripting and a lot of trial and error to do things that once seemed obvious. To be reduced to this after almost 40 years of programming is devastating and until I discovered ImageMagick I had lost interest even in basic web building.

Now, I'm beginning to get my head around a few of the principles involved. Which I suppose is why I persist in writing scripts to do this stuff instead of just hijacking Fred's, your and others' work wholesale.

Thanks again. I hope that little script gives some other people some ideas - especially if they have a point and shoot camera like my Fuji S1500 and are disappointed with the results.

I have applied that script to hundreds of photos taken on a range of cameras back to the 1980s. It is not brilliant on stuff exposed on film, although it does improve a lot of them. But for anything taken on a 'basic' digital camera it makes a huge difference.