Here's the code
Whenever the the values of RGB in array is under 100 the code works fine but the moment any value exceed 100 it shows that indexerror . I have also realized that I get this error with images with multiple colours (pictures taken with camera) and it works fine with images created with softwares with 2 or 3 colours
And here's the error message
Python:
`` pim = Image.open('try.png').convert('RGB')
im = np.array(pim)
def closest(colors,color):
colors = np.array(colors)
color = np.array(color)
distances = np.sqrt(np.sum((colors-color)**2,axis=2))
index_of_smallest =
np.where(distances==np.amin(distances))
smallest_distance = colors[index_of_smallest]
return smallest_distance
closest_color = closest(im,color)
print(closest_color )
A,B,C = closest_color[1] ``
Whenever the the values of RGB in array is under 100 the code works fine but the moment any value exceed 100 it shows that indexerror . I have also realized that I get this error with images with multiple colours (pictures taken with camera) and it works fine with images created with softwares with 2 or 3 colours
And here's the error message
Python:
[[224 189 69]]
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iie
c_run/iiec_run.py", line 31, in <module> start(fakepyfile,
mainpyfile) File
"/data/user/0/ru.iiec.pydroid3/files/accomp_files/iie
c_run/iiec_run.py", line 30, in start exec(open
(mainpyfile).read(), main _dict_) File "<string>", line 22, in
<module> IndexError: index 1 is out of bounds for axis 0
with size 1
[Program finished]