1. An image processing apparatus comprising: one or more processors; and at least one memory storing instructions which, when executed by the one or more processors, cause the image processing apparatus to: obtain information on each pixel of a target region associated with a target pixel, and information on each pixel of a reference region associated with reference pixels, in image data; determine whether a reference pixel is the same pixel as the target pixel, based on the obtained information; derive a weight according to a similarity between the target region and the reference region according to a result of the determination; and decide a pixel value of the target pixel according to the weight and a pixel value of the reference pixel, wherein the instructions, when executed by the one or more processors, further cause the image processing apparatus to: in a case where the target pixel is used as the reference pixel, switch between derivation methods so as to derive a weight for the target pixel by a different method from that in a case where the target pixel and the reference pixel are not the same, and in a case where it is determined that the target pixel matches the reference pixel, derive a set value as a weight for the reference pixel as the target pixel, wherein the set value is equal to or more than 0 and is 5 or less times the expected value of the weight in a case where the pixel value of the target region and the pixel value of the reference region are same value as each other when a noise component is disregarded.