How to reduce execution time of a code in matlab R2013a

1 view (last 30 days)
Attached is the complete code for "Copy move image forgery detection using PCA". The input and output required are also attached with the post. Problem is this code works only for input1, and for other input images it just shows its input image as the output. Please help to rectify the code.kindly also suggest something to reduce the execution time of the code which is nearly 15 minutes.
  3 Comments
harpreet
harpreet on 22 May 2015
Sir Brendan Hamm, I mean to say that As i entered the path for image named 'input1' in the code, it gave correct result. So, i tested it on some more images (as attached input2, input3 etc.), Then it didn't give correct output as required. Instead it resulted in the same output as that of image.
harpreet
harpreet on 22 May 2015
Although the code is not a function, but it needs an image as its input( in the first line of the code) and gives another image as its output

Sign in to comment.

Answers (1)

Brendan Hamm
Brendan Hamm on 22 May 2015
Edited: Brendan Hamm on 22 May 2015
To reduce execution time, run the code in the Profiler.
Looking at your code I would suggest attempting to remove the loops if possible and vectorize your code. Furthermore, I would suggest not using the disp() function inside of a for-loop as this takes valuable resources and is not usually necessary. Lastly pre-allocate space for x1,*y1*,etc. that are assigned in the loop. By not pre-allocating you are making a new copy of the data stored in the vector at every iteration in your loop.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!