-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ testing wand.Image.function('sinusoid')
Related to issue #4 - trying to find better modifiers for the function() call on images. Currently, the parameters for img.function('sinusoid') are being randomly generated, and it is a good idea to restrict the range of parameter generation so that results are more consistent and do not come out too dark or with a gray filter.
- Loading branch information
1 parent
7960b71
commit 45cbb71
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
IMGS="sine_tests/freq_phase" | ||
DIR="sine_tests/freq_phase/results" | ||
|
||
if [[ ! -d ${DIR} ]]; then | ||
mkdir ${DIR} | ||
fi | ||
|
||
for i in {1..10}; do | ||
montage ${IMGS}/${i}_-30.jpg ${IMGS}/${i}_-45.jpg -tile 2x1 -geometry +0+0 ${IMGS}/row_${i}.jpg | ||
COUNT=-60 | ||
while [[ $COUNT -ge -90 ]]; do | ||
montage ${IMGS}/row_${i}.jpg ${IMGS}/${i}_${COUNT}.jpg -tile 2x1 -geometry +0+0 ${IMGS}/row_${i}.jpg | ||
COUNT=$((COUNT-15)) | ||
done | ||
done | ||
|
||
echo "created rows; sleeping for 3 seconds before continuing" | ||
sleep 3 | ||
|
||
montage ${IMGS}/row_1.jpg ${IMGS}/row_2.jpg -tile 1x2 -geometry +0+0 ${DIR}/result_1-5.jpg | ||
for i in {3..5}; do | ||
montage ${DIR}/result_1-5.jpg ${IMGS}/row_${i}.jpg -tile 1x2 -geometry +0+0 ${DIR}/result_1-5.jpg | ||
sleep 2 | ||
done | ||
echo "finished result file for rows 1-5" | ||
|
||
montage ${IMGS}/row_6.jpg ${IMGS}/row_7.jpg -tile 1x2 -geometry +0+0 ${DIR}/result_6-10.jpg | ||
for i in {8..10}; do | ||
montage ${DIR}/result_6-10.jpg ${IMGS}/row_${i}.jpg -tile 1x2 -geometry +0+0 ${DIR}/result_6-10.jpg | ||
sleep 2 | ||
done | ||
|
||
echo "done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os | ||
from wand.image import Image | ||
from shutil import copyfile | ||
import glob | ||
import pdb | ||
|
||
def generate_images(filename): | ||
outdir = './sine_tests' | ||
if not os.path.isdir(outdir): | ||
os.mkdir(outdir) | ||
else: | ||
for filename in glob.glob(outdir + '/*.*'): | ||
os.remove(filename) | ||
# four parameters for sinusoid transform: | ||
# name current range result? | ||
# 1. frequency 1 to 10 ? | ||
# 2. phase shift -90 to -25 ? | ||
# 3. amplitude 0.1 to 0.9 best guess: gray filter | ||
# 4. bias 0.1 to 0.9 lighten/darken | ||
for frequency in range(1, 10): | ||
for phase_shift in range(-90, -30, 15): | ||
for amplitude in range(1, 9): | ||
for bias in range(1, 9): | ||
params = [frequency, phase_shift, amplitude * 0.1, bias * 0.1] | ||
with Image(filename=filename) as img: | ||
img.modulate(200, 300) | ||
img.function('sinusoid', params) | ||
ampl = '%.1f' % params[2] | ||
biases = '%.1f' % params[3] | ||
img.save(filename= outdir + '/{}_{}_{}_{}.jpg'.format(params[0], params[1], ampl, biases)) | ||
|
||
def test_frequency_phase(filename): | ||
outdir = './sine_tests/freq_phase' | ||
if not os.path.isdir(outdir): | ||
os.mkdir(outdir) | ||
for frequency in range(1, 11): | ||
for phase_shift in range(-90, -15, 15): | ||
params = [frequency, phase_shift, 0.9, 0.5] | ||
with Image(filename=filename) as img: | ||
img.modulate(200, 300) | ||
img.function('sinusoid', params) | ||
img.save(filename= outdir + '/{}_{}.jpg'.format(frequency, phase_shift)) | ||
|
||
test_frequency_phase('./stock_images/bce223b38aeed99d.jpeg') | ||
|
||
# generate_images('./stock_images/bce223b38aeed99d.jpeg') |