I have a code that analysis images. The code analyzes only one image at a time and then shows the resulting analysis in the shell:
%matplotlib inline
from matplotlib import pyplot as plt
FILEPATH = 'AnomalousImages/'
shortname = '3rd.png'
imagefile = FILEPATH+shortname
ggimg = cv2.imread(imagefile,0)
maxintensity = np.amax(ggimg)
enhancefactor = 255./maxintensity
temp = enhancefactor*ggimg
hhimg = temp.astype(int)
print('Max intensity = ',maxintensity)
print('Enhancement factor = {0:.3f}'.format(enhancefactor))
print('Image dimensions',hhimg.shape)
plt.imshow(hhimg,cmap = 'gray')
plt.show()
brightpixels=np.nonzero(ggimg>THRESHOLD2-1)
numbright = len(brightpixels[0])
print('numbright = ',numbright)
if numbright > 0:
for i in range(0,numbright):
print('(',brightpixels[0][i],brightpixels[1][i],ggimg[brightpixels[0][i],brightpixels[1][i]],')',end='')
The problem is, there are over a hundred images inside the FILEPATH folder, and I need to do run this code for every picture in that folder. Instead of running this code one at a time for each image, I want to do them all at once but I'm not sure how.
I'm...pretty sure this is a very basic task, but I'm a very beginner coder. I'm pretty sure I have to use a for loop and have been messing around with the code trying to figure it out myself but to no avail.
Thanks in advance!