sequence of image processing using the same background
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi everybody I have a batch of images. For each image, I am using the same background image. How can I analyze all images using the same background image? When I read the one image, I will have to change the name of the background image as well, but I can not manage to change the background image name for each image that I need to analyze. I would also appreciate if you give me some info, suggestion regarding analyzing the batch of images in the same code?
Thanks!!!
채택된 답변
Image Analyst
2018년 5월 22일
See the FAQ for code samples: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Inside the loop, create the new background image filename and read it in with imread(). Then read in the test image and use both of them to do your analysis.
댓글 수: 11
Thanks for the reply. I have been trying to sort it out, but I could not. I have images and I can import them in the matlab, but I don't have mat1.mat or file1.txt? What are those? Do I need to just read the images then, and delete the other codes? Inside the loop, do I need to read the background image (it is the same for other images that I wanna process the algorithm) as in reading batch of images?
Did you see both code samples? Or just the first one? What are your files named? Any pattern you want, or just analyze all of them with a particular extension?
Yes I have seen. Let's say I have 10 images such as image1.png,image2.png....image10.png . and I have only one background image which is backgroundimage.png. How can I implement this into my code? Please tell me If I am not clear, as I am new in Matlab.
all files are png.
read the background image before the loop
backgroundImage = imread(.........
fileList = dir(fullfile(yourFolder, '*.png'));
for k = 1 : length(fileList)
thisFileName = fullfile(fileList(k).folder, fileList(k).name);
thisImage = imread(thisFileName);
% Do something with thisImage and backgroundImage....
end
I tried to read the background image first but still, I could not make it work. I sent my initial code. What would you suggest based on the code I sent to read a batch of images by using just one background image.
You read in the very same file name for both the RGB image and the background image. Plus you did not have a loop over all images. Please answer these 3 questions:
- What is the name of the background image you want to use with every image?
- What is the file pattern for the RGB images you want to batch process? For example *.png or whatever...
- How do you want to use the background image with the RGB images? For example, divide them, subtract them, or what???
engineer
2018년 5월 25일
편집: Image Analyst
2018년 5월 25일
- Let's say the name of the background image is example_background.png which will be used with every image.
- PNG
- Divide them
Try this:
% Specify the folder where the files live.
myFolder = 'C:\Users\yourUserName\Documents\My Pictures';
% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
backgroundFullFileName = fullfile(myFolder, 'example_background.png');
if ~exist(backgroundFullFileName, 'file')
errorMessage = sprintf('Error: Background file does not exist:\n%s', backgroundFullFileName);
uiwait(errordlg(errorMessage));
else
backgroundImage = imread(backgroundFullFileName);
[rowsB, columnsB, numberOfColorChannelsB] = size(backgroundImage);
end
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.PNG'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
thisImage = imread(fullFileName);
imshow(thisImage); % Display image.
[rows, columns, numberOfColorChannels] = size(backgroundImage);
drawnow; % Force display to update immediately.
if rows ~= rowsB || columns ~= columnsB
thisImage = imresize(thisImage, size(backgroundImage));
end
correctedImage = double(thisImage) ./ double(backgroundImage);
imshow(correctedImage);
drawnow;
% Now do whatever you want with correctedImage, such as image analysis.
end
Thank you very much. I was able to read all images including my background image. However, When I run the programme, correctedImage was full of white. I checked its pixel, it consist of just pixel 1, which is totaly white. What would be the problem? I could get a good background-corrected image.
Unfortunately you forgot to include your code, and I'm heading off to the airport in a couple of hours. Try this:
imshow(correctedImage, []);
It's possible that your background image is darker than your test images so the ratio is always greater than one so you need the empty brackets in imshow().
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Sequences and Batch Processing에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
