-
-
Save anonymous/34abe26431e21920e83c6cf7a57a852c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Image imageDiff(Image img1, Image img2){ | |
| Bitmap gazou1 = new Bitmap(img1); | |
| Bitmap gazou2 = new Bitmap(img2); | |
| //画像サイズが小さい方に合わせる | |
| int ht = gazou1.Height; | |
| int wt = gazou1.Width; | |
| if (gazou1.Width > gazou2.Width){ | |
| wt = gazou2.Width; | |
| } | |
| if (gazou1.Height > gazou2.Height){ | |
| ht = gazou2.Height; | |
| } | |
| Bitmap btDiff = new Bitmap(wt,ht); | |
| Image imgDiff; | |
| for (int i = 0; i < wt; i++){ | |
| for (int j = 0; j < ht; j++){ | |
| if (gazou1.GetPixel(i, j) == gazou2.GetPixel(i, j)){ | |
| //一致ならば比較元のピクセルデータをそのまま格納 | |
| btDiff.SetPixel(i, j, gazou1.GetPixel(i, j)); | |
| }else{ | |
| //不一致ならば結果に紫色を格納 | |
| btDiff.SetPixel(i, j, Color.BlueViolet); | |
| } | |
| } | |
| } | |
| imgDiff = btDiff; | |
| return imgDiff; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment