-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvisualizer.py
More file actions
46 lines (37 loc) · 1.36 KB
/
Copy pathvisualizer.py
File metadata and controls
46 lines (37 loc) · 1.36 KB
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
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import argparse
import sys
import math
import random
from PIL import Image
import cv2
class Visualizer(object):
def __init__(self, imageShape, numCompare=2):
self.NumCompare = numCompare
self.ImageShape = imageShape
self.Count = [0] * numCompare
self.Masks = np.zeros((numCompare,) + imageShape, dtype=np.float32)
def DisplayMask(self):
# TODO: convert mask from float to uint8 to display 0 to 255
pass
def AddImage(self, image, compareNum):
proccessedImage = self.ProcessImage(image)
mask = self.FeatureMaskDetect(image)
self.AppendMask(mask, compareNum)
def ProcessImage(self, image):
# TODO: add any preprocessing to the image as nessacery
return image
def FeatureMaskDetect(self, image):
mask = np.zeros_like(image)
# TODO: Add in Color Range filter and append it to the mask
return mask
def AppendMask(self, mask, compareNum):
totalMask = self.Masks[compareNum] * self.Count[compareNum]
addedTotalMask = totalMask + mask
averagedMask = addedTotalMask/(self.Count[compareNum]+1)
self.Masks[compareNum] = averagedMask
self.Count[compareNum] += 1