-
Notifications
You must be signed in to change notification settings - Fork 0
/
Code-1.py
107 lines (60 loc) · 1.64 KB
/
Code-1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# importing libraries
from glob import glob
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
import cv2
dataset_path = 'D:/IMAGEE SEG/4j/*.jpg'
set1 = glob(dataset_path)
#reading images of set1
#blue image
blue = Image.open(set1[0])
blue.size
#green image
green = Image.open(set1[1])
green.size
#red image
red= Image.open(set1[2])
red.size
#Pan image
pan = Image.open(set1[3])
pan.size
#code to display images
#blue image
fig, ax = plt.subplots(figsize=(10, 10))
ax.imshow(blue,cmap='gray')
ax.axis('off')
plt.show()
#green image
fig, ax = plt.subplots(figsize=(10, 10))
ax.imshow(green,cmap='gray')
ax.axis('off')
plt.show()
#red image
fig, ax = plt.subplots(figsize=(10, 10))
ax.imshow(red,cmap='gray')
ax.axis('off')
plt.show()
#pan image
fig, ax = plt.subplots(figsize=(10, 10))
ax.imshow(pan,cmap='gray')
ax.axis('off')
plt.show()
# Merge the RGB channels into a single image
multi = Image.merge('RGB', (red, green, blue))
# plot the merged image
fig, ax = plt.subplots(figsize=(10, 10))
ax.imshow(multi)
ax.axis('off')
plt.show()
multi_w , multi_h = multi.size
#Resizing Panchromatic Image according to the multispectral
resized_pan = pan.resize((multi_w , multi_h))
#plotting resized panchromatic image
fig, ax = plt.subplots(figsize=(10, 10))
ax.imshow(resized_pan,cmap='gray')
ax.axis('off')
plt.show()
#exporting the fused Multi-spectral image and resized Panchromatic Image
multi.save('D:/IMAGEE SEG/Processed imgs/4j_Multi.jpg')
resized_pan.save('D:/IMAGEE SEG/Processed imgs/4j_pan.jpg' )