Example Imagine you just have three tiles, so your df_tiles Dataframe is: II your image subset has ave r=10, ave s=200,
Example Imagine you just have three tiles, so your df_tiles Dataframe is: II your image subset has ave r=10, ave s=200, and ave_b =20, we can use the distance formula (Pythagorean’s Theorem) to find how “far awby” the average color is from each of the tile images: 1. For the red the (255,0,0), the distance away is d=(255−10)2+(0−200)2+(0−20)2=316.8990375 2. For the green tile (0,255,0, the distance away is d=(0−10)2+(255−200)2+(0−20)2=59.37171044 3. For the blue tile (0,0,255), the distance awoy is d=(0−10)2+(0−200)2+(255−20)2=308.7474696 We find that the green tile is the closest since it has the minimum distance. The green tle should be retumed. Section 8: Finding the Best Match There’s just one last function. This function needs to find the best tile for a given average color. To do this, you will use two pleces of data: 1. You will use the DataFrame of all of your tile images that is generated in the previous section. This will be passed into your function as df_tiles. 2. You will use the average color of a subset of your image. This is passed into your function as aver., ave 2 and ave. b. Using this data, findBesti1le must find the best tile image from df_tiles for a given average color. You should do this by finding the single row in df_tiles that has the smallest distance from the average colos Typeterrer Trueebeck (Cost recent coll last) 3e2. tryy 303 – For exposition, write: 384 – yarr – isinstance (y, npindarray) (…) – Then cates were this gons through whout roloting ineludes 310 – (xint or xbool) and (yint or bool) →311 result =op(x,y) 312 except typetirror: Durlas handing of the obove exeeptlon, onother exception occurred: valuatrrer Trecaback (east recent eall 1ast) 32try1 326 except ( 127 Typetrior, 32 voluetrior, (+∞) 39 motteplementederror, 396 fland scolar of type [( typ )] ” 337 ) from err Hints – It will be VERY helpful to add an extra column to your Dataframe — Ike df[“distance”] – .. – Once you have the distance calculated, how do you retum just the smallest row? theort nath raturn en11udistance * a test case fer section 8 es (6) ees Tratebeck (Gost recent call 1ast)
OR