Skip to content

Commit 630daa2

Browse files
authored
Add files via upload
1 parent e75d350 commit 630daa2

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

raw2tiff.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# 趣味のPython学習 Project 02-12
22
# Python RAW 2 TIFF CONVERTER
3-
# ばーじょん 0.1.1
3+
# ばーじょん 0.1.2
44

5-
ver = "0.1.1"
5+
ver = "0.1.2"
66

77
# NEED THIS ! get 'pillow' with pip command !
88
from PIL import Image
@@ -34,6 +34,8 @@
3434

3535
raw = RPY.imread(fnm)
3636

37+
tif = raw.postprocess(demosaic_algorithm=RPY.DemosaicAlgorithm.LINEAR,output_bps=16)
38+
3739
width = raw.sizes.width
3840
height = raw.sizes.height
3941
clr = raw.color_desc
@@ -44,9 +46,6 @@
4446
print("PATTERN:",clr)
4547
print(pat)
4648

47-
tif = raw.postprocess(demosaic_algorithm=RPY.DemosaicAlgorithm.LINEAR,output_bps=16)
48-
rgb = raw.postprocess(demosaic_algorithm=RPY.DemosaicAlgorithm.LINEAR,four_color_rgb=True,output_color=RPY.ColorSpace.raw,output_bps=16)
49-
5049
print("*** READ OK ***")
5150

5251
except LibRawIOError:
@@ -63,21 +62,22 @@
6362

6463
if type(pat) != numpy.ndarray : continue
6564

66-
fno = fnm + ".reb.png"
65+
rgb = raw.postprocess(half_size=True,four_color_rgb=True,output_color=RPY.ColorSpace.raw,output_bps=16)
66+
67+
fno = fnm + ".rb.png"
6768
print(f"*** SAVE : {fno} ( 16bit bayer pattern ) ***")
6869

6970
img_cv = Image.new('I;16',(width,height))
7071

7172
for y in range(height) :
7273
for x in range(width) :
7374

74-
if x%2 == 0 and y%2 == 0 : c = pat[0][0]
75-
if x%2 == 1 and y%2 == 0 : c = pat[0][1]
76-
if x%2 == 0 and y%2 == 1 : c = pat[1][0]
77-
if x%2 == 1 and y%2 == 1 : c = pat[1][1]
78-
if c == 3 : c = 1
75+
if x%2 == 0 and y%2 == 0 : c = 0
76+
if x%2 == 1 and y%2 == 0 : c = 1
77+
if x%2 == 0 and y%2 == 1 : c = 3
78+
if x%2 == 1 and y%2 == 1 : c = 2
7979

80-
img_cv.putpixel((x,y),int(rgb[y][x][c]))
80+
img_cv.putpixel((x,y),int(rgb[y//2][x//2][c]))
8181

8282
img_cv.save(fno)
8383

0 commit comments

Comments
 (0)