{"action":"created","issue":{"url":"https://api.github.com/repos/opencv/opencv/issues/5045","repository_url":"https://api.github.com/repos/opencv/opencv","labels_url":"https://api.github.com/repos/opencv/opencv/issues/5045/labels{/name}","comments_url":"https://api.github.com/repos/opencv/opencv/issues/5045/comments","events_url":"https://api.github.com/repos/opencv/opencv/issues/5045/events","html_url":"https://github.com/opencv/opencv/issues/5045","id":97443485,"number":5045,"title":"seamlessClone takes time proportional to the size of the image","user":{"login":"opencv-pushbot","id":2051563,"avatar_url":"https://avatars.githubusercontent.com/u/2051563?v=3","gravatar_id":"","url":"https://api.github.com/users/opencv-pushbot","html_url":"https://github.com/opencv-pushbot","followers_url":"https://api.github.com/users/opencv-pushbot/followers","following_url":"https://api.github.com/users/opencv-pushbot/following{/other_user}","gists_url":"https://api.github.com/users/opencv-pushbot/gists{/gist_id}","starred_url":"https://api.github.com/users/opencv-pushbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencv-pushbot/subscriptions","organizations_url":"https://api.github.com/users/opencv-pushbot/orgs","repos_url":"https://api.github.com/users/opencv-pushbot/repos","events_url":"https://api.github.com/users/opencv-pushbot/events{/privacy}","received_events_url":"https://api.github.com/users/opencv-pushbot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/opencv/opencv/labels/affected:%20master","name":"affected: master","color":"ededed"},{"url":"https://api.github.com/repos/opencv/opencv/labels/auto-transferred","name":"auto-transferred","color":"ededed"},{"url":"https://api.github.com/repos/opencv/opencv/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/opencv/opencv/labels/category:%20photo","name":"category: photo","color":"ededed"},{"url":"https://api.github.com/repos/opencv/opencv/labels/priority:%20normal","name":"priority: normal","color":"A38700"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2015-07-27T11:36:15Z","updated_at":"2016-09-19T08:19:54Z","closed_at":null,"body":"Transferred from http://code.opencv.org/issues/4445\r\n```\n|| David Doria on 2015-06-27 23:31\n|| Priority: Normal\n|| Affected: branch 'master' (3.0-dev)\n|| Category: None\n|| Tracker: Bug\n|| Difficulty: \n|| PR: \n|| Platform: x64 / Linux\n```\n\nseamlessClone takes time proportional to the size of the image\n-----------\n```\nI've found that with a fixed hole size, when the size of the image increases the runtime increases substantially. For example, if I fill a 200x200 hole in a 500x500 image, it takes < 1 second. Then if I fill a 200x200 hole in a 3000x3000 image, it takes 20 seconds. The 500x500 was a cropped version of the 3000x3000 so that the hole and source could be identical for testing to make sure it wasn't a function of the data in the hole, etc.\r\n\r\nMy guess is that some processing is happening (derivatives being computed, etc.) over the whole image, even though they are only needed inside the source or hole region.\n```\n\nHistory\n-------\n##### Philipp Hasper on 2015-07-02 07:47\n```\nThanks for reporting. Could you add a minimal source code example?\n```"},"comment":{"url":"https://api.github.com/repos/opencv/opencv/issues/comments/247934786","html_url":"https://github.com/opencv/opencv/issues/5045#issuecomment-247934786","issue_url":"https://api.github.com/repos/opencv/opencv/issues/5045","id":247934786,"user":{"login":"stalin18","id":4315056,"avatar_url":"https://avatars.githubusercontent.com/u/4315056?v=3","gravatar_id":"","url":"https://api.github.com/users/stalin18","html_url":"https://github.com/stalin18","followers_url":"https://api.github.com/users/stalin18/followers","following_url":"https://api.github.com/users/stalin18/following{/other_user}","gists_url":"https://api.github.com/users/stalin18/gists{/gist_id}","starred_url":"https://api.github.com/users/stalin18/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stalin18/subscriptions","organizations_url":"https://api.github.com/users/stalin18/orgs","repos_url":"https://api.github.com/users/stalin18/repos","events_url":"https://api.github.com/users/stalin18/events{/privacy}","received_events_url":"https://api.github.com/users/stalin18/received_events","type":"User","site_admin":false},"created_at":"2016-09-19T08:19:54Z","updated_at":"2016-09-19T08:19:54Z","body":"@mshabunin I've submitted a PR #7308 which fixes this issue. Basically in the original code, full size images are passed to Cloning::normalClone() function, this leads to reconstruction of full image and hence incurs more time for a bigger size image even if the hole size is same.\r\n\r\nIn my fix, I'm passing only the rectangular roi regions from destination, source, mask and output image. I've tested it on sample ([opencv_extra](https://github.com/opencv/opencv_extra/tree/master/testdata/cv/cloning)) as well as other images and it is giving results with visually no difference from current code results; also there is a significant improvement in the execution time. However, following 3 tests are always failing for my fix:\r\n\r\n- Photo_SeamlessClone_normal.regression :\r\n/build-2/precommit_linux64/opencv/modules/photo/test/test_cloning.cpp:89: Failure\r\nExpected: (error) <= (numerical_precision), actual: **826877** vs 1000\r\n\r\n- Photo_SeamlessClone_mixed.regression :\r\n/build-2/precommit_linux64/opencv/modules/photo/test/test_cloning.cpp:120: Failure\r\nExpected: (error) <= (numerical_precision), actual: **147501** vs 1000\r\n\r\n- Photo_SeamlessClone_featureExchange.regression :\r\n/build-2/precommit_linux64/opencv/modules/photo/test/test_cloning.cpp:152: Failure\r\nExpected: (error) <= (numerical_precision), actual: **1.26313e+06** vs 1000\r\n\r\nAfter analysing and debugging, I conclude that the above testcases cannot be passed because I  suspect that the reference images which are being used from [here](https://github.com/opencv/opencv_extra/tree/master/testdata/cv/cloning) are obtained in similar fashion, i.e., reconstruction of entire image rather than only hole. That's why the L1 norm for my result images is high. I've confirmed this by computing the L1 norm of **_destination images_** with **_reference images_** (in [opencv_extra](https://github.com/opencv/opencv_extra/tree/master/testdata/cv/cloning)) and **_images obtained with my fixed code_**. This is what I have got:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/4315056/18625762/3d714e06-7e6e-11e6-978f-7fae32d4763c.png)\r\n\r\nAs it is evident, the L1 norm for reference images is very high compared to L1 norm of cloned images obtained with my fixed code. \r\n\r\nI think the reference images which are being used for Normal clone, Mixed clone and Monochrome transform from [here](https://github.com/opencv/opencv_extra/tree/master/testdata/cv/cloning) must be created in the same way: reconstruction of only the hole.  I would like to know your views on this."}}
{"actor":{"display_login":"stalin18"}}