contrast image processing ultrasound
이전 댓글 표시
Hi guys we are calculating the contrast of a cyst inside an ultrasound image. With the code we select the square ROI manually, but then we also need a ROI of the same size to calculate the background. Then extract from the medium cyst the level of gray and variance. Can you help us?
im= imread('_258.tif');
imshow(im);
c_im=imcrop(im);
c_im=rgb2gray(c_im);
imshow(c_im);
xmed=mean2(c_im);
xstd=std2(c_im);
댓글 수: 2
Image Analyst
2020년 5월 16일
Does the background box surround the cyst box, or is it beside it? Do you just want to manually drag out a box around the cyst, and then point to the center of the other background box?
ALESSIA PAPPA
2020년 5월 16일
채택된 답변
추가 답변 (1개)
Image Analyst
2020년 5월 16일
Try this:
grayImage = imread('Cameraman.tif');
imshow(grayImage);
roi = drawrectangle
row1 = roi.Position(2);
row2 = roi.Position(2) + roi.Position(4);
col1 = roi.Position(1);
col2 = roi.Position(1) + roi.Position(3);
% Get the mean in that box
meanGL = mean2(grayImage(row1:row2, col1:col2))
% Compute area
height1 = (row2-row1 + 1)
width1 = (col2 - col1 + 1)
area = height1 * width1
% Make a box twice as big.
height2 = sqrt(2) * height1;
width2 = sqrt(2) * width1
% Get the midpoint
middleRow = mean([row1, row2])
middleCol = mean([col1, col2])
xline(middleCol, 'Color', 'r', 'LineWidth', 2);
yline(middleRow, 'Color', 'r', 'LineWidth', 2);
row1 = round(middleRow - height2/2)
row2 = round(middleRow + height2/2)
col1 = round(middleCol - width2/2)
col2 = round(middleCol + width2/2)
hold on
rectangle('Position', [col1, row1, width2, height2], 'EdgeColor', 'y', 'LineWidth', 2);
% Get the mean in that box
meanGL = mean2(grayImage(row1:row2, col1:col2))

카테고리
도움말 센터 및 File Exchange에서 ROI-Based Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

