Counting overlapping pixels between two images
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I'm looking to find the number of overlapping shaded pixels between two images. The two images are attached. How could I count the overlapping shaded red pixels between the two images? Any assistance would be much appreciated. If possible an easily repeatable process, as I have to run it with 64 images.
채택된 답변
Image Analyst
2014년 7월 18일
Call imregister to align them. Then use min() to take the min values of the two images.
By the way, I'll be soon leaving for canoe camping over the weekend so good luck. I'll be back Sunday afternoon.
댓글 수: 11
Thanks for all your help, have a great trip!
If you're still around could you quickly help me with what A would be in my case (using min(A,[],dim), right?)? I'm confused by the min help site.
A would be the two images stacked:
A = cat(3, image1, image2);
See if that works. If not, do it on each color channel one at a time.
So here's my code so far. Am I on the right track? I'm not getting any error messages but I'm also not getting a min value when I run the script.
Not really. This will take a while to fix...
This is about all I had time for:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 13;
filename = {'CMHJ_A1FC';'CMHJ_A2FC';'CMHJ_A3FC';'CMHJ_A4FC';'CMHJ_A5FC';'CMHJ_A6FC';...
'CMHJ_A7FC';'CMHJ_A8FC';'CMHJ_B1FC';'CMHJ_B2FC';'CMHJ_B3FC';...
'CMHJ_B4FC';'CMHJ_B5FC';'CMHJ_B6FC';'CMHJ_B7FC';'CMHJ_B8FC'};
folder = 'C:\Users\Matt\Documents\Temporary';
fixedFileName = fullfile(folder, 'CMHJ_P1FC.jpg');
if ~exist(fixedFileName, 'file')
message = sprintf('Moving file name #%d does not exist:\n%s\nSkipping it.', k, fixedFileName);
uiwait(v(message));
return;
end
fixedReference = imread (fixedFileName);
subplot(1, 3, 1);
imshow(fixedReference);
title('Fixed Reference Image', 'fontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
drawnow;
for k = 1 : length(filename)
movingFileName = fullfile(folder, sprintf('%s.jpg', filename{k}));
if ~exist(movingFileName, 'file')
promptMessage = sprintf('Moving file name #%d does not exist:\n%s\nSkipping it.', k, movingFileName);
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
break;
end
continue;
end
movedImage = imread (movingFileName);
subplot(1, 3, 2);
imshow(movedImage);
caption = sprintf('Moved image: %s', filename{k});
title(caption, 'fontSize', fontSize, 'Interpreter', 'none');
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
drawnow;
% Register the moved image to the fixed, reference image.
% imshowpair (fixedReference, movedImage);
%
% fixedReference = rgb2gray (fixedReference);
% movedImage = rgb2gray (movedImage);
% [optimizer, metric] = imregconfig ('multimodal');
% movingRegisteredDefault = imregister (fixedReference, movedImage, 'affine', optimizer, metric);
% subplot(1, 3, 2);
% imshowpair (movingRegisteredDefault, movedImage)
% title('reg', 'fontSize', fontSize);
stackedImage = cat(3, movedImage, fixedReference);
minImage = min(stackedImage, [], 3);
subplot(1, 3, 3);
imshow(minImage);
title('Combined Image', 'fontSize', fontSize);
promptMessage = sprintf('Do you want to Continue processing,\nor Cancel to quit processing?');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
break;
end
end
Okay thanks for your help, hope you had a good canoe trip
How to calculate overlap measure between two x-ray images , and the picture is attached to the message. Please answer a question. Thank you

mohamed, start a new question and attach your two original images, and the code that found the red and green coordinates. And clearly specify what is the overlap area you want. Is it the area that is common to both the green and red outlines regions
I want the code that defines the green points on the mask, and calculates the overlap between the area that is common to both the green and red outlines regions, the code that I have specifies the red line only on the image

Image Analyst
2020년 12월 29일
편집: Image Analyst
2020년 12월 29일
Well just do something similar to get the green line. I'm not sure what is different - maybe a different parameter at some point in your algorithm. Then you can get the mask for each and AND them:
[rows, columns, numberOfColorChannels] = size(yourImage);
redMask = poly2mask(xRed, yRed, rows, columns];
greenMask = poly2mask(xGreen, yGreen, rows, columns];
overlap = redMask & greenMask;
overlapArea = nnz(overlap);
Again, let's take this to a different thread, so we don't keep sending Matthew emails about new activity in his 6 year old question. You can reply here ONCE again, ONLY to put the link to your new question.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Explore and Edit Images with Image Viewer App에 대해 자세히 알아보기
참고 항목
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)
