Ejemplo n.º 1
0
import scipy

#get the image path
imagePath=sys.argv[1]
#set output filename
outName=sys.argv[2]
#open the image
image=Image.open(imagePath)
#image as numpy array
image=numpy.asarray(image)
#keep only one dimension
image=image[:,:,0]
#most needed type casting
image=image.astype(numpy.uint8)
#crop the center
image=myTools.cropCenter1(image, 83.1)
#split image to 4
splits=myTools.augmentData(image.reshape(1,1,image.shape[0],image.shape[1]), numOfTiles=4, overlap=False, imageWidth=image.shape[0], imageHeight=image.shape[1])
#another vital type casting
splits=splits.astype(numpy.float32)
#keep only the 4 original tiles
splits=splits[0:4,:,:,:]
#setting parameters for the network
data_size=(None,1,splits[0][0].shape[0],splits[0][0].shape[1])
#load the pretrained network
myNet=myTools.createPretrainedNN(data_size)
#make predictions for the 4 tiles
print(splits.dtype)
res=myNet(splits)
#crop the center of the predictions
res=myTools.cropCenter(res, 93)
Ejemplo n.º 2
0
from os import listdir
from os.path import isfile, join
from sklearn.metrics import mean_squared_error
from math import sqrt

#get the produced masks' path
imagePath = sys.argv[1]

#get all images' names
filenames = [f for f in listdir(imagePath) if isfile(join(imagePath, f))]

rmseList = list()

for f in filenames:
    #open the image
    myMask = Image.open(imagePath + '/' + f, 'r')
    #image as numpy array
    myMask = numpy.asarray(myMask)
    myMask = myTools.cropCenter1(myMask, 100)

    #open the expert mask
    theMask = Image.open('../../masksExpertTest/' + '/' + f, 'r')
    #image as numpy array
    theMask = numpy.asarray(theMask)

    thisRMSE = sqrt(mean_squared_error(theMask, myMask))

    rmseList.append(thisRMSE)

print(numpy.mean(rmseList))
Ejemplo n.º 3
0
import scipy

#get the image path
imagePath = sys.argv[1]
#set output filename
outName = sys.argv[2]
#open the image
image = Image.open(imagePath)
#image as numpy array
image = numpy.asarray(image)
#keep only one dimension
image = image[:, :, 0]
#most needed type casting
image = image.astype(numpy.uint8)
#crop the center
image = myTools.cropCenter1(image, 100)
#this step is mysteriously needed
image = myTools.augmentMasks(image.reshape(1, 1, image.shape[0],
                                           image.shape[1]),
                             numOfTiles=1,
                             overlap=False,
                             imageWidth=image.shape[0],
                             imageHeight=image.shape[1])
#another vital type casting
image = image.astype(numpy.float32)
#setting parameters for the network
data_size = (None, 1, image[0][0].shape[0], image[0][0].shape[1])
#load the pretrained network
myNet = myTools.createPretrainedNN(data_size)
#make predictions for the image
res = myNet(image)
Ejemplo n.º 4
0
from sklearn.metrics import mean_squared_error
from math import sqrt

#get the produced masks' path
imagePath=sys.argv[1]

#get all images' names
filenames = [f for f in listdir(imagePath) if isfile(join(imagePath, f))]

rmseList=list()

for f in filenames:
    #open the image
    myMask=Image.open(imagePath + '/' + f, 'r')
    #image as numpy array
    myMask=numpy.asarray(myMask)
    myMask=myTools.cropCenter1(myMask, 100)

    #open the expert mask
    theMask=Image.open('../../masksExpertTest/' + '/' + f, 'r')
    #image as numpy array
    theMask=numpy.asarray(theMask)

    thisRMSE = sqrt(mean_squared_error(theMask, myMask))

    rmseList.append(thisRMSE)



print(numpy.mean(rmseList))
Ejemplo n.º 5
0
#get the image path
imagePath=sys.argv[1]
#get the threshold level
thresh=float(sys.argv[2])
#get the erosion shape
er=int(sys.argv[3])
#open the image
image=Image.open(imagePath)
#image as numpy array
image=numpy.asarray(image)
#keep only one dimension
image=image[:,:,0]
#most needed type casting
image=image.astype(numpy.uint8)
#crop the center
image=myTools.cropCenter1(image, 80)
#split image to 4
splits=myTools.augmentMasks(image.reshape(1,1,image.shape[0],image.shape[1]), numOfTiles=4, overlap=False, imageWidth=image.shape[0], imageHeight=image.shape[1])
#another vital type casting
splits=splits.astype(numpy.float32)
#keep only the 4 original tiles
splits=splits[0:4,:,:,:]
#setting parameters for the network
data_size=(None,1,splits[0][0].shape[0],splits[0][0].shape[1])
#load the pretrained network
myNet=myTools.createPretrainedNN(data_size)
#make predictions for the 4 tiles
res=myNet(splits)
#concatenate on the x axis
top=np.concatenate((res[0][0],res[1][0]),axis=1)
bot=np.concatenate((res[2][0],res[3][0]),axis=1)
Ejemplo n.º 6
0
import scipy

#get the image path
imagePath=sys.argv[1]
#set output filename
outName=sys.argv[2]
#open the image
image=Image.open(imagePath)
#image as numpy array
image=numpy.asarray(image)
#keep only one dimension
image=image[:,:,0]
#most needed type casting
image=image.astype(numpy.uint8)
#crop the center
image=myTools.cropCenter1(image, 100)
#this step is mysteriously needed
image=myTools.augmentMasks(image.reshape(1,1,image.shape[0],image.shape[1]), numOfTiles=1, overlap=False, imageWidth=image.shape[0], imageHeight=image.shape[1])
#another vital type casting
image=image.astype(numpy.float32)
#setting parameters for the network
data_size=(None,1,image[0][0].shape[0],image[0][0].shape[1])
#load the pretrained network
myNet=myTools.createPretrainedNN(data_size)
#make predictions for the image
res=myNet(image)
#crop the center of the mask
res=myTools.cropCenter(res, 80)


plt.show(plt.imshow(res[0][0], cmap=cm.binary))