1. An image-based object counting method comprising: rasterizing a counting line in an image into counting line pixels; determining two points on a trajectory line included in the image as target pixels; determining, from the counting line pixels, corresponding pixels that correspond to the target pixels; determining whether the counting line intersects with the trajectory line based on the target pixels and the corresponding pixels; and determining a number of one or more trajectory lines including the trajectory line that intersect with the counting line as a number of objects that pass the counting line, wherein the determining of whether the counting line intersects with the trajectory line comprises determining that the counting line intersects with the trajectory line when a first result of comparison between a first target pixel from the target pixels and a first corresponding pixel corresponding to the first target pixel is different from a second result of comparison between a second target pixel from the target pixels and a second corresponding pixel corresponding to the second target pixel, the determining of the corresponding pixels comprises, when one of two direction coordinates is a reference direction coordinate, determining, as the corresponding pixels, pixels having same reference direction coordinate values as the target pixels from among the counting line pixels, the determining of whether the counting line intersects with the trajectory line comprises, when the other direction coordinate is a comparative direction coordinate, determining, as the first result of the comparison, whether a difference between a comparative direction coordinate value of the first target pixel and a comparative direction coordinate value of the first corresponding pixel is greater than 0, and determining, as the second result of the comparison, whether a difference between a comparative direction coordinate value of the second target pixel and a comparative direction coordinate value of the second corresponding pixel is greater than 0, and the determining of the corresponding pixels comprises determining one of the two direction coordinates as the reference direction coordinate and determining the other direction coordinate as the comparative direction coordinate, based on an inclination of the counting line.