




'''simple docstring'''





from __future__ import annotations

from pathlib import Path





def UpperCAmelCase						(					UpperCAmelCase_      ,  UpperCAmelCase_	):
    return pointa[0] * pointa[1] - pointa[1] * pointa[0]





def UpperCAmelCase						(					UpperCAmelCase_      ,  UpperCAmelCase_      ,  UpperCAmelCase_      ,  UpperCAmelCase_      ,  UpperCAmelCase_      ,  UpperCAmelCase_	):
    _a							:       tuple[int, int]       					=			(xa, ya)
    _a							:       tuple[int, int]       					=			(xa - xa, ya - ya)
    _a							:       tuple[int, int]       					=			(xa - xa, ya - ya)
    _a							:       float       					=			-vector_product(UpperCAmelCase_      ,  UpperCAmelCase_	) / vector_product(
        UpperCAmelCase_      ,  UpperCAmelCase_	)
    _a							:       float       					=			+vector_product(UpperCAmelCase_      ,  UpperCAmelCase_	) / vector_product(
        UpperCAmelCase_      ,  UpperCAmelCase_	)

    return a > 0 and b > 0 and a + b < 1





def UpperCAmelCase						(					UpperCAmelCase_ = "p102_triangles.txt"	):
    _a							:       str       					=			Path(UpperCAmelCase_	).parent.joinpath(UpperCAmelCase_	).read_text(encoding="""utf-8"""	)

    _a							:       list[list[int]]       					=			[]
    for line in data.strip().split("""\n"""	):
        triangles.append([int(UpperCAmelCase_	) for number in line.split(""","""	)]	)

    _a							:       int       					=			0
    _a							:       list[int]

    for triangle in triangles:
        ret += contains_origin(*UpperCAmelCase_	)

    return ret


if __name__ == "__main__":
  print(F"""{solution() = }""")








'''simple docstring'''





from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import divide, inta, multiply, ravel, sort, zeros_like





def UpperCAmelCase						(					UpperCAmelCase_      ,  UpperCAmelCase_=3	):
    _a							:       Optional[Any]       					=			int(mask / 2	)
    # copy image size
    _a							:       Optional[int]       					=			zeros_like(UpperCAmelCase_	)
    for i in range(UpperCAmelCase_      ,  gray_img.shape[0] - bd	):
        for j in range(UpperCAmelCase_      ,  gray_img.shape[1] - bd	):
            # get mask according with mask
            _a							:       List[str]       					=			ravel(gray_img[i - bd : i + bd + 1, j - bd : j + bd + 1]	)
            # calculate mask median
            _a							:       Optional[Any]       					=			sort(UpperCAmelCase_	)[inta(divide((multiply(UpperCAmelCase_      ,  UpperCAmelCase_	))      ,  2	) + 1	)]
            _a							:       int       					=			median
    return median_img


if __name__ == "__main__":
  # read original image
  a		:  List[Any]   			=			imread('''../image_data/lena.jpg''')
  # turn image in gray scale value
  a		:  Optional[Any]   			=			cvtColor(img, COLOR_BGR2GRAY)

  # get values with two different mask size
  a		:  str   			=			median_filter(gray, 3)
  a		:  Optional[Any]   			=			median_filter(gray, 5)

  # show result images
  imshow('''median filter with 3x3 mask''', medianaxa)
  imshow('''median filter with 5x5 mask''', medianaxa)
  waitKey(0)


