aspenlin wrote:Furthermore, is there any way to make this wavy image more straight?
The image has four long wavy horizontal lines. You can straighten any one of them by moving entire columns up or down, but that will make some lines worse.
Suppose we want to straighten both the top and bottom lines. The image can be shrunk vertically, with most shrinking where the lines are furthest apart. We can shrink vertically with a displacement map. The following assumes the midline of the image is already straight. Windows BAT syntax:
Code: Select all
%IMG7%magick ^
labtest4.jpg ^
+write mpr:ORIG ^
+depth ^
( +clone -blur 0x5 ) ^
-compose DivideSrc -composite ^
+write d.png ^
-contrast-stretch 10%%,80%% ^
-threshold 50%% ^
-crop 1760x+5+0 +repage ^
-morphology Convolve Blur:0x10 ^
+write c0.png ^
-threshold 20%% ^
+write c.png ^
-fill Black ^
-draw "color 0,0 floodfill" ^
-draw "color 0,%%[fx:h-1] floodfill" ^
-fill Blue ^
-draw "color 0,0 floodfill" ^
-draw "color 0,%%[fx:h-1] floodfill" ^
-fill White +opaque Blue ^
-fill Black -opaque Blue ^
+write f.png ^
-set option:MYSIZE %%[fx:w]x%%[fx:h] ^
-trim +repage ^
+write t.png ^
-scale "x1^!" ^
-define compose:clamp=off ^
-evaluate Subtract %%[min] ^
-scale "%%[MYSIZE]^!" ^
( +clone ^
-sparse-color bilinear 0,0,Black,0,%%[fx:h-1],White ^
-evaluate Subtract 50%% ^
+write t2.png ^
) ^
-compose Multiply -composite ^
-evaluate Add 50%% ^
-channel R -evaluate Set 50%% +channel ^
+write g.png ^
mpr:ORIG ^
+swap ^
-compose Displace -composite ^
labtest_out.jpg

For simplicity, I have trimmed the left and right edges. Some more work would correct that.
Each "+write X.png" is for debugging only, and can be removed.
The result makes the top and bottom lines parallel, though neither is exactly straight. More work could make them exactly straight.