In [18]:
%matplotlib inline

import numpy as np
from scipy.misc import imread, imresize
import matplotlib.pyplot as plt

import rawpy
import imageio

ori_input_array = ["ler.raw", "whorl.raw", "rloop.raw", "linsfN.raw", "linsfT.raw", "Frogs.jpg"];
otsu_input_array = ["otsu_ler.raw", "otsu_whorl.raw", "otsu_rloop.raw", "otsu_linsfN.raw", "otsu_linsfT.raw", "otsu_Frogs.raw"]
icmX_input_array = ["icmX_ler.raw", "icmX_whorl.raw", "icmX_rloop.raw", "icmX_linsfN.raw", "icmX_linsfT.raw", "icmX_Frogs.raw"];

m_array = [100, 512, 512, 640, 640, 3264];
n_array = [100, 512, 512, 896, 896, 2448];

In [30]:
## combine


def read_image(img_file):
    img = np.fromfile(img_file, 'uint8')
    if img.shape[0] == m_array[pic_index] * n_array[pic_index] +1:
        img = img[:-1]

    img = img.reshape(m_array[pic_index], n_array[pic_index])
    return img


pic_index = 5


for pic_index in range(5):
    
    plt.figure(figsize=(20, 20))

    ori_pic = './pic_data/' + ori_input_array[pic_index]
    otsu_pic = './output_raw_pic/' + otsu_input_array[pic_index]
    icmX_pic = './output_raw_pic/' + icmX_input_array[pic_index]
    
    plt.subplot(1, 3, 1)
    plt.title(ori_input_array[pic_index], fontsize=20)
    img = read_image(ori_pic)
    plt.imshow(img)  

    plt.subplot(1, 3, 2)
    plt.title(otsu_input_array[pic_index], fontsize=20)
    img = read_image(otsu_pic)
    plt.imshow(img)  

    plt.subplot(1, 3, 3)
    plt.title(icmX_input_array[pic_index], fontsize=20)
    img = read_image(icmX_pic)
    plt.imshow(img)  
    
#     plt.tight_layout()
    plt.savefig('./output_result/' + ori_input_array[pic_index] + '_.png', dpi=300)



In [88]:
'output_raw_frog'




def read_frog_image(img_file):
    img = np.fromfile(img_file, 'uint8')
    m = 2448 #3264
    n = 3264 #2448
    if img.shape[0] == m * n +1:
        img = img[:-1]
#     print (img.shape)    
    img = img.reshape(m, n)
#     print (img.shape)    
    return img


plt.figure(figsize=(20, 20))

plt.subplot(1, 3, 1)
plt.title('otsu_frog_0.raw', fontsize=20)
img = read_frog_image('./output_raw_frog/' + 'otsu_frog_0.raw')
plt.imshow(img)  

plt.subplot(1, 3, 2)
plt.title('otsu_frog_1.raw', fontsize=20)
img = read_frog_image('./output_raw_frog/' + 'otsu_frog_1.raw')
plt.imshow(img)  

plt.subplot(1, 3, 3)
plt.title('otsu_frog_2.raw', fontsize=20)
img = read_frog_image('./output_raw_frog/' + 'otsu_frog_2.raw')
plt.imshow(img)


Out[88]:
<matplotlib.image.AxesImage at 0x1050ac9b0>

In [89]:
plt.figure(figsize=(20, 20))

plt.subplot(1, 3, 1)
plt.title('icmX_frog_0.raw', fontsize=20)
img = read_frog_image('./output_raw_frog/' + 'icmX_frog_0.raw')
plt.imshow(img)  

plt.subplot(1, 3, 2)
plt.title('icmX_frog_1.raw', fontsize=20)
img = read_frog_image('./output_raw_frog/' + 'icmX_frog_1.raw')
plt.imshow(img)  

plt.subplot(1, 3, 3)
plt.title('icmX_frog_2.raw', fontsize=20)
img = read_frog_image('./output_raw_frog/' + 'icmX_frog_2.raw')
plt.imshow(img)


Out[89]:
<matplotlib.image.AxesImage at 0x108422eb8>

In [ ]:


In [35]:
## deal frog

frog_index = 5

frog_pic = './pic_data/' + ori_input_array[frog_index]

img = imread(frog_pic)
# # img.show()
plt.imshow(img)


Out[35]:
<matplotlib.image.AxesImage at 0x108fc2a58>

In [36]:
img.shape


Out[36]:
(2448, 3264, 3)

In [ ]:


In [78]:
frog_pic = './pic_data/' + ori_input_array[frog_index]
img = imread(frog_pic)
plt.imshow(img)


Out[78]:
<matplotlib.image.AxesImage at 0x1095171d0>

In [85]:
from scipy.misc import imsave


def read_frog_image(img_file):
    img = np.fromfile(img_file, 'uint8')
    m = 2448 #3264
    n = 3264 #2448
    if img.shape[0] == m * n +1:
        img = img[:-1]
    print (img.shape)    
    img = img.reshape(m, n)
    print (img.shape)    
    return img

frog_pic = './pic_data/' + ori_input_array[frog_index]
img = imread(frog_pic)
plt.imshow(img) 

frog_0 = img[:,:,0]
frog_1 = img[:,:,1]
frog_2 = img[:,:,2]

for i in range(1):
    
    frog_part = img[: , :, i]
    
#     imsave('./frog_data/frog_'+ str(i) +'.png', frog_part)  ## not use image
#     frog_part.astype('uint8')
    
#     frog_part = frog_part.reshape(2448, 3264)
    
    frog_part.tofile('./test_test/frog_'+ str(i) +'.raw')
    

    img = read_frog_image('./test_test/frog_'+ str(i) +'.raw')

#     img = img.transpose()

    plt.imshow(img)


(7990272,)
(2448, 3264)

In [ ]:


In [40]:
frog_0


Out[40]:
array([[ 83,  84,  83, ..., 177, 178, 179],
       [ 84,  85,  83, ..., 177, 178, 179],
       [ 86,  86,  84, ..., 177, 178, 179],
       ..., 
       [178, 179, 180, ..., 176, 176, 176],
       [178, 179, 180, ..., 176, 176, 176],
       [178, 179, 180, ..., 176, 176, 176]], dtype=uint8)

In [ ]:


In [ ]:
##########

In [98]:
%matplotlib inline

import numpy as np
from scipy.misc import imread, imresize
import matplotlib.pyplot as plt

import rawpy
import imageio

ori_input_array = ["ler.raw", "whorl.raw", "rloop.raw", "linsfN.raw", "linsfT.raw", "Frogs.jpg"];
otsu_input_array = ["otsu_ler.raw", "otsu_whorl.raw", "otsu_rloop.raw", "otsu_linsfN.raw", "otsu_linsfT.raw", "otsu_Frogs.raw"]
icmX_input_array = ["icmX_ler.raw", "icmX_whorl.raw", "icmX_rloop.raw", "icmX_linsfN.raw", "icmX_linsfT.raw", "icmX_Frogs.raw"];

m_array = [100, 512, 512, 640, 640, 3264];
n_array = [100, 512, 512, 896, 896, 2448];




####


def read_image(img_file):
    img = np.fromfile(img_file, 'uint8')
    if img.shape[0] == m_array[pic_index] * n_array[pic_index] +1:
        img = img[:-1]

    img = img.reshape(m_array[pic_index], n_array[pic_index])
    return img


pic_index = 5


plt.figure(figsize=(21, 30))


for pic_index in range(5):
    
    ori_pic = './pic_data/' + ori_input_array[pic_index]
    otsu_pic = './output_raw_pic/' + otsu_input_array[pic_index]
    icmX_pic = './output_raw_pic/' + icmX_input_array[pic_index]
    
    i = pic_index
    
    plt.subplot(7, 3, 1+i*3)
    plt.title(ori_input_array[pic_index], fontsize=20)
    img = read_image(ori_pic)
    plt.imshow(img)  

    plt.subplot(7, 3, 2+i*3)
    plt.title(otsu_input_array[pic_index], fontsize=20)
    img = read_image(otsu_pic)
    plt.imshow(img)  

    plt.subplot(7, 3, 3+i*3)
    plt.title(icmX_input_array[pic_index], fontsize=20)
    img = read_image(icmX_pic)
    plt.imshow(img)  
    
#     plt.tight_layout()



# ####



def read_frog_image(img_file):
    img = np.fromfile(img_file, 'uint8')
    m = 2448 #3264
    n = 3264 #2448
    if img.shape[0] == m * n +1:
        img = img[:-1]
#     print (img.shape)    
    img = img.reshape(m, n)
#     print (img.shape)    
    return img


# plt.figure(figsize=(20, 20))

plt.subplot(7, 3, 1+5*3)
plt.title('otsu_frog_0.raw', fontsize=20)
img = read_frog_image('./output_raw_frog/' + 'otsu_frog_0.raw')
plt.imshow(img)  

plt.subplot(7, 3, 2+5*3)
plt.title('otsu_frog_1.raw', fontsize=20)
img = read_frog_image('./output_raw_frog/' + 'otsu_frog_1.raw')
plt.imshow(img)  

plt.subplot(7, 3, 3+5*3)
plt.title('otsu_frog_2.raw', fontsize=20)
img = read_frog_image('./output_raw_frog/' + 'otsu_frog_2.raw')
plt.imshow(img)  


###


# plt.figure(figsize=(20, 20))

plt.subplot(7, 3, 1+6*3)
plt.title('icmX_frog_0.raw', fontsize=20)
img = read_frog_image('./output_raw_frog/' + 'icmX_frog_0.raw')
plt.imshow(img)  

plt.subplot(7, 3, 2+6*3)
plt.title('icmX_frog_1.raw', fontsize=20)
img = read_frog_image('./output_raw_frog/' + 'icmX_frog_1.raw')
plt.imshow(img)  

plt.subplot(7, 3, 3+6*3)
plt.title('icmX_frog_2.raw', fontsize=20)
img = read_frog_image('./output_raw_frog/' + 'icmX_frog_2.raw')
plt.imshow(img)  



##
plt.tight_layout()   ## try

plt.savefig('./output_result/Final_21_30.png', dpi=300)      

print('save OK!')


save OK!

In [ ]: