def imageSegmentor(imageFilePath, matFilePath):
mat = readMatFile(matFilePath); # read mat file
image = getImage(imageFilePath); # input the image
typeOfFruit = getTypeOfFruit(image); # on basis of counting or temperature value there are 2 types of fruit
plt.imshow(image);
_fft = getFFT(image);
_mag = getMag(_fft);
_ang = getAngleInDegrees(_fft);
edges = edgeDetector(image); # detects the edges of the image
_segmentation = segmentation(image, typeOfFruit); # segments different parts of image
filteredImage = filterImageFromSegmentation(image, _segmentation); # filter the object part of image
outputMatrix = imageMapping(filteredImage, mat['IR']); # map the value part of the image and else 0
prefix = re.split('IR_|.pgm', imageFilePath)[0];
postfix = re.split('IR_|.pgm', imageFilePath)[1];
nameOfFile = prefix + "csv_"
nameOfFile = nameOfFile + postfix;
print(nameOfFile);
writeToCSV(outputMatrix, nameOfFile); # write it to the CSV file
writeFF2CSV(outputMatrix, _mag, _ang, nameOfFile);
fig, ((fig1, fig2), (fig3, fig4)) = plt.subplots(2, 2, figsize = (10, 8)); # subplot the different plots
fig1.imshow(image, cmap = plt.cm.gray); # colormap used here is gray
fig2.imshow(image, cmap = plt.cm.gray);
fig3.imshow(edges, cmap = plt.cm.gray);
fig4.imshow(filteredImage, cmap = plt.cm.gray);
return
# header file
评论列表
文章目录