Commit 42431013 authored by Tilmann Sager's avatar Tilmann Sager
Browse files

Fixed line drawing in detection // working state

parent 75f05e03
[general]
multiprocessing = 0
multiprocessing = 1
limit = 0
[product]
......
......@@ -65,7 +65,7 @@ def detect_lines_blockwise(granule: {}, params: {}):
if granule.get(col.flight_count) <= 0:
return granule
img = granule.get(col.cda_i)
img = granule.get(col.cda)
split_by = 0
# Split blocks
......
......@@ -77,7 +77,7 @@ def _correct_value(val, shape):
return int(val)
# TODO: refactor
# DO NOT TOUCH THIS CODE, IT DOES NOT WANT TO BE REFACTORED SO PLEASE LEAVE IT LIKE THIS
def get_line_label_intersections(labeled: np.array, line_peaks, shape: (int, int)) -> [int]:
intersections = []
......@@ -86,20 +86,21 @@ def get_line_label_intersections(labeled: np.array, line_peaks, shape: (int, int
if angle == 0.0:
continue
points = _peaks_to_points(angle, dist, shape)
y0 = _correct_value((dist - 0 * np.cos(angle) / np.sin(angle)), shape[0])
y1 = _correct_value((dist - shape[1] * np.cos(angle) / np.sin(angle)), shape[1])
x0 = 0
x1 = _correct_value(shape[1], shape[1])
if points is None:
if y0 is None or y1 is None or x0 is None or x1 is None:
continue
line_arr = np.zeros(labeled.shape, dtype=int)
rr, cc = sk_line(*points)
rr, cc = sk_line(x1, x0, y1, y0)
line_arr[rr, cc] = 1
for label_num in range(1, labeled.max()):
if label_num == 0:
continue
mask = labeled == label_num
masked = line_arr * mask
......@@ -109,6 +110,38 @@ def get_line_label_intersections(labeled: np.array, line_peaks, shape: (int, int
return list(set(intersections))
# def _line_segment_intersect(labeled, h, theta, d, threshold, shape):
# intersections = []
#
# for _, angle, dist in zip(*hough_line_peaks(h, theta, d, threshold=threshold * h.max())):
#
# if angle == 0.0:
# continue
#
# y0 = _correct_value((dist - 0 * np.cos(angle) / np.sin(angle)), shape[0])
# y1 = _correct_value((dist - shape[1] * np.cos(angle) / np.sin(angle)), shape[1])
# x0 = 0
# x1 = _correct_value(shape[1], shape[1])
#
# if y0 is None or y1 is None or x0 is None or x1 is None:
# continue
#
# line_arr = np.zeros(labeled.shape, dtype=int)
# rr, cc = line(x1, x0, y1, y0)
# line_arr[rr, cc] = 1
#
# for label_num in range(1, labeled.max()):
# if label_num == 0:
# continue
# mask = labeled == label_num
# masked = line_arr * mask
#
# if masked.any():
# intersections.append(label_num)
#
# return list(set(intersections))
# TODO: combine to one method (or several)
def line_segment_intersect_prob(labeled: np.array, lines: []) -> [int]:
intersections = []
......
......@@ -6,14 +6,13 @@ from common.config import init_params
from common.constants import columns_to_save
from common.fileio import write_results, write_config
from common.path import create_path
import os
params = init_params()
results_file = create_path([params.get('output_dir'), 'results.csv'])
config_file = create_path([params.get('output_dir'), 'config.json'])
# input_files = glob(params.get('hdf_dir') + '/*.hdf')
input_files = [os.path.join(params.get('hdf_dir'), 'MODTBGA.A2012094.h15v03.006.2015240000438.hdf')]
input_files = glob(params.get('hdf_dir') + '/*.hdf')
# input_files = [os.path.join(params.get('hdf_dir'), 'MODTBGA.A2012094.h15v03.006.2015240000438.hdf')]
limit = params.get('limit')
......
from extraction import hdf, flights
from preprocessing import cda, misc
from preprocessing import cda
from detection import hough
from plot import plots
......@@ -21,7 +21,6 @@ def run(filepath: str, params: {}):
PREPROCESSING
"""
granule = cda.preprocess_image(granule, params)
granule = misc.preprocess_image(granule, params)
"""
DETECTION
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment