This file contains hidden or 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
# Show the direction of landslide | |
fig = plt.figure() | |
ax = fig.add_subplot(111) | |
ax.plot(bf_cX, bf_cY, 'go') | |
# ax.text(bf_cY+1, bf_cX-2, 'center point of region - before landslide') | |
ax.plot(at_cX, at_cY, 'ro') | |
# ax.text(at_cY+1, at_cX+1, 'center point of region - before landslide') |
This file contains hidden or 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
# Reference from **Bidimensional Empirical Mode Decomposition** code by Dawid Laszuk ([email protected]). | |
# This version is modified by H-BEMD for sin and cos value and optimize Extrema detection and Normolization value | |
# By Trong-An Bui ([email protected] - http://buitrongan.com) | |
class BEMD: | |
def __init__(self): | |
# ProtoIMF related | |
self.mse_thr = 0.01 | |
self.mean_thr = 0.01 | |
self.FIXE = 1 # Single iteration by default, otherwise results are terrible |
This file contains hidden or 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
hueradians = np.deg2rad(hue_16bit) | |
cos_hueradians = np.cos(hueradians) | |
sin_hueradians = np.sin(hueradians) | |
# BEMD in sin value of hue channel | |
bemd2 = BEMD() | |
imfs_sin_hue = bemd2.bemd(sin_hueradians, max_imf=2) | |
# BEMD in cos value of hue channel | |
bemd = BEMD() |
This file contains hidden or 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
bgrInputImage = cv2.imread(img_path) | |
bgrInputImage = cv2.resize(bgrInputImage,(224,224)) | |
rgb_resized_img = cv2.cvtColor(bgrInputImage,cv2.COLOR_BGR2RGB) | |
hsvInputImage_Full = cv2.cvtColor(rgb_resized_img.astype(np.float32), cv2.COLOR_RGB2HSV_FULL) | |
hue_full, sat_full, val_full = cv2.split(hsvInputImage_Full) | |
hue_16bit = np.array(hue_full,dtype=np.uint16) |
This file contains hidden or 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
for e in coordinates: | |
show_ship(e[0][0], e[0][1], e[1][0][1]) | |
picture_tensor = picture_tensor.transpose(1,2,0) | |
picture_tensor.shape | |
plt.figure(1, figsize = (15, 30)) | |
plt.subplot(3,1,1) | |
plt.imshow(picture_tensor) |
This file contains hidden or 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
step = 10; coordinates = [] | |
for y in range(int((height-(80-step))/step)): | |
for x in range(int((width-(80-step))/step) ): | |
area = cutting(x*step, y*step) | |
result = model.predict(area) | |
if result[0][1] > 0.90 and not_near(x*step,y*step, 88, coordinates): | |
coordinates.append([[x*step, y*step], result]) | |
print(result) | |
plt.imshow(area[0]) | |
plt.show() |
This file contains hidden or 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
def cutting(x, y): | |
area_study = np.arange(3*80*80).reshape(3, 80, 80) | |
for i in range(80): | |
for j in range(80): | |
area_study[0][i][j] = picture_tensor[0][y+i][x+j] | |
area_study[1][i][j] = picture_tensor[1][y+i][x+j] | |
area_study[2][i][j] = picture_tensor[2][y+i][x+j] | |
area_study = area_study.reshape([-1, 3, 80, 80]) | |
area_study = area_study.transpose([0,2,3,1]) | |
area_study = area_study / 255 |
This file contains hidden or 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
image = Image.open('./ships-in-satellite-imagery/scenes/scenes/sfbay_1.png') | |
pix = image.load() | |
n_spectrum = 3 | |
width = image.size[0] | |
height = image.size[1] | |
# creat vector | |
picture_vector = [] | |
for chanel in range(n_spectrum): |
This file contains hidden or 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
# optimization setup | |
sgd = SGD(lr=0.01, momentum=0.9, nesterov=True) | |
model.compile( | |
loss='categorical_crossentropy', | |
optimizer=sgd, | |
metrics=['accuracy']) | |
# training | |
model.fit( | |
X_train, |
This file contains hidden or 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
model = Sequential() | |
model.add(Conv2D(32, (3, 3), padding='same', input_shape=(80, 80, 3), activation='relu')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) #40x40 | |
model.add(Dropout(0.25)) | |
model.add(Conv2D(32, (3, 3), padding='same', activation='relu')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) #20x20 | |
model.add(Dropout(0.25)) |