Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Could someone help me with a code, it's very URGENT
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hey people,
I need a help, because I don't know how to extricate myself from a code. My code has to compare two binary images. Image 1 has just some pixels with value 0 and that is also case for Image 2. So, task of my code is to compare if those pixels are overlapped, and if so, overlapped pixels on Image 2 would get a value 1. It has do a recursion for a set of binary images.
I give you my unfinished code, but there are some written comments what it needs to do at those lines.
myFolderInput = 'F:\input_with_flakes\';
myFolderOutput= 'F:\output_wihout_flakes\';
if ~isdir(myFolderInput)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolderInput);
uiwait(warndlg(errorMessage));
return;
end
if ~isdir(myFolderOutput)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolderOutput);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolderInput, '*.jpg');
jpegFiles = dir(filePattern);
for k = 1:length(jpegFiles)
baseFileName = jpegFiles(k).name;
fullFileName = fullfile(myFolderInput, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = imread(fullFileName);
[i j]=size(imageArray)
if k==1
fprintf('The first one is skipped\n')
else
for m=1:i
for n=1:j
if imageArray(m,n)==imageArray(m,n) % if Previous Image(m,n)==Current Image(m,n)
imageArray(m,n)=1; % Current Image(m,n)=1;
elseif imageArray(m,n)==0 % elseif Current Image(m,n)==0
imageArray(m,n)=0; % Current Image(m,n)=0;
end
end
end
end
filename = sprintf('Excluded_%s', baseFileName);
imwrite(imageArray,[myFolderOutput, filename],'jpeg');
end
1 commentaire
Adrian
le 25 Juil 2012
Hello,
first of all, in my view at least, I see some logical problems. You have to load the second image(I did not work with images); the comparison "imageArray(m,n)==imageArray(m,n)" will always be true. Second thing I noticed is that if your "imageArray(m,n)==0", you will have a 1 because "imageArray(m,n)==imageArray(m,n)" is always true. I would say to modify the code in order to load the second image, than compare the first image pixel with 0 and only afterwards to check between the two images. It really depends on what you want to happen if imageArray(m,n) is 0.
Best regards,
Adrian
Réponses (0)
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!