-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Each channel of Image for segmentation
- Loading branch information
Madhav Khosla
committed
Jul 22, 2019
1 parent
ce4bc75
commit 3a0fc3b
Showing
32 changed files
with
6 additions
and
20 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,10 @@ | ||
from utils.one_hot_encoder import HotEncoder | ||
import numpy as np | ||
import torch | ||
import skimage | ||
img__= skimage.io.imread("/Users/madhav/Desktop/Screenshot 2019-07-17 at 11.27.51 PM.png") | ||
encoder= HotEncoder(dir= "/Users/madhav/Desktop/", extension="png", is_binary= False) | ||
from torch.nn.functional import one_hot | ||
img__= skimage.io.imread("/Users/madhav/DataSets/data_semantics/training/semantic_rgb/000035_10.tif") | ||
encoder= HotEncoder(dir= '/Users/madhav/DataSets/data_semantics/training/semantic_rgb', extension="tif", is_binary= False, n_classes= 30) | ||
color_dict= encoder.gen_colors() | ||
|
||
def rgb_to_onehot(rgb_arr, color_dict): | ||
num_classes = len(color_dict) | ||
shape = rgb_arr.shape[:2]+(num_classes,) | ||
arr = np.zeros( shape, dtype=np.int8 ) | ||
for i, cls in enumerate(color_dict): | ||
arr[:,:,i] = np.all(rgb_arr.reshape( (-1,3) ) == color_dict[i], axis=1).reshape(shape[:2]) | ||
return arr | ||
|
||
|
||
def onehot_to_rgb(onehot, color_dict): | ||
single_layer = np.argmax(onehot, axis=-1) | ||
output = np.zeros( onehot.shape[:2]+(3,) ) | ||
for k in color_dict.keys(): | ||
output[single_layer==k] = color_dict[k] | ||
return np.uint8(output) | ||
class_mat= encoder.PerPixelClassMatrix(img__) | ||
print(class_mat) | ||
onehottt= encoder.PerPixelClassMatrix(img__) | ||
encoded= encoder.HotEncode(onehottt) |