이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
how to identify high-intensity pixel ?
조회 수: 4 (최근 30일)
이전 댓글 표시
marwa za
2017년 10월 4일
Can anyone help me to identify high-intensity regions for segmenting the tumor( image of the brain as the following figure)
답변 (1개)
Image Analyst
2017년 10월 4일
편집: Image Analyst
2017년 10월 4일
Try thresholding. See attached demo.
Also see my Image Segmentation Tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
댓글 수: 28
marwa za
2017년 10월 4일
I tried with your code, but it shows me the following error: Undefined function 'bwareafilt' for input arguments of type 'double'. Error in bl2 (line 152) binaryTumorImage = bwareafilt(binaryImage, 1);
Image Analyst
2017년 10월 5일
You have an old version of MATLAB. Just replace the line with something like
binaryTumorImage = bwareaopen(binaryImage, 100);
This will possibly get you multiple blobs though, instead of just one. However you can increase the second argument to make it big enough so that only your largest blob gets extracted.
marwa za
2017년 10월 12일
thanks, please tell me what is called the method you used in the step of extracting the skull
Image Analyst
2017년 10월 12일
You can call it "skull stripping" overall. It uses "thresholding" as one of the main steps of it.
marwa za
2017년 10월 15일
please can you give me the the explanation of the part " find tumor boundaries ", really I want in my work.
Image Analyst
2017년 10월 15일
At that point in the code, there is already a binary image that says where the tumor is and isn't. That part of the code simply calls bwboundaries() to get a list of (x,y) coordinates of the outer perimeter of the binary blob that indicates the tumor.
marwa za
2017년 10월 16일
for the part (Threshold the image) , if we change the image we must also change the threshold value, can you give me a solution where we don't need to change each time the threshold value.
Image Analyst
2017년 10월 16일
Sorry, no. If the image changes, you must compute a new threshold value, and you must come up with an algorithm for that, or you can do it interactively using my visual thresholding app: http://www.mathworks.com/matlabcentral/fileexchange/29372-thresholding-an-image
marwa za
2017년 10월 16일
can you help me, which function allows to calculate the low and the high value of the threshold (histogram)
like the following histogram
Image Analyst
2017년 10월 16일
Well one way might be to zero out the counts from 0 to 50 or so. Then find the highest peak. Then find the lowest point from that peak to the right side. Like
counts(1:50) = 0;
[maxValue, indexOfMax] = max(counts);
counts(1:indexOfMax) = maxValue;
[minValue, threshold] = min(counts);
Image Analyst
2017년 10월 17일
편집: Image Analyst
2017년 10월 17일
What is "exuction"?
DON'T name your function hist. There is a built in function by that name that you should not destroy.
Image Analyst
2017년 10월 18일
Try this:
clc; % Clear command window.
clear; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
fontSize = 25;
grayImage=imread('2.jpg');
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
grayImage = rgb2gray(grayImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
% grayImage = grayImage(:, :, 2); % Take green channel.
end
% Display the image.
subplot(2,2,1);
imshow(grayImage);
title('Original Gray Scale Image', 'FontSize', fontSize);
% Display the histogram so we can see what gray level we need to threshold it at.
subplot(2,2,3:4);
hObj = histogram(grayImage, 256)
grid on;
title('Histogram', 'FontSize', fontSize, 'Interpreter', 'None')
% Find threshold.
counts = hObj.Values;
counts(1:50) = 0;
[maxValue, indexOfMax] = max(counts);
counts(1:indexOfMax) = maxValue;
[minValue, threshold] = min(counts)
hold on;
line([threshold, threshold], ylim, 'Color', 'r', 'LineWidth', 2);
xticks(0:20:255);
% Binarize image
binaryImage = grayImage > threshold;
subplot(2,2,2);
imshow(binaryImage);
title('Binary Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
marwa za
2017년 10월 18일
thank you, it displays the high and low threshold value, just it displays the following error: How to correct it please :
Undefined function or variable 'xticks'.
Error in newhist (line 36)
xticks(0:20:255);
Image Analyst
2017년 10월 18일
Just remove that line completely, or else upgrade your MATLAB. It came along in a newer version of MATLAB than you have.
Image Analyst
2017년 10월 31일
Threshold the skullFreeImage instead of the original gray scale image. Then use the mask to erase everything from the image except the tumor.
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 = 20;
grayImage=imread('2.jpg');
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
grayImage = rgb2gray(grayImage);
end
%%%%%%%%%%
subplot(2,3,1);
imshow(grayImage);
title('Original Grayscale Image', 'FontSize', fontSize);
% Display the histogram so we can see what gray level we need to threshold it at.
subplot(2, 3, 2:3);
hObj = histogram(grayImage, 256)
grid on;
title('Histogram', 'FontSize', fontSize, 'Interpreter', 'None')
% Find threshold.
counts = hObj.Values;
counts(1:50) = 0;
[maxValue, indexOfMax] = max(counts);
counts(1:indexOfMax) = maxValue;
[minValue, threshold] = min(counts)
hold on;
line([threshold, threshold], ylim, 'Color', 'r', 'LineWidth', 2);
%xticks(0:20:255);
% Binarize image
binaryImage = grayImage > threshold;
subplot(2,3,4);
imshow(binaryImage);
title('Binary Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
%%%%%%%%%%%
% Extract the outer blob, which is the skull.
% The outermost blob will have a label number of 1.
labeledImage = bwlabel(binaryImage); % Assign label ID numbers to all blobs.
binaryImage = ismember(labeledImage, 1); % Use ismember() to extract blob #1.
% Thicken it a little with imdilate().
binaryImage = imdilate(binaryImage, true(5));
% Display the final binary image.
subplot(2, 3, 5);
imshow(binaryImage, []);
axis on;
caption = sprintf('Extraction Skull ');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
%%%%%%%%%%%
% Mask out the skull from the original gray scale image.
skullFreeImage = grayImage; % Initialize
skullFreeImage(binaryImage) = 0; % Mask out.
% Display the image.
subplot(2, 3, 6);
imshow(skullFreeImage, []);
axis on;
caption = sprintf('Gray Scale Image\nwith Skull Stripped Away');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
%%%%%%%%%%%
% Give user a chance to see the results on this figure, then offer to continue and find the tumor.
promptMessage = sprintf('Do you want to continue and find the tumor,\nor Quit?');
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if strcmpi(buttonText, 'Quit')
return;
end
% Now threshold to find the tumor
binaryImage = skullFreeImage > threshold;
% Display the image.
hFig2 = figure();
subplot(2, 2, 1);
imshow(binaryImage, []);
axis on;
caption = sprintf('Initial Binary Image\nThresholded at %d Gray Levels', threshold);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
%%%%%%%%%%%
% Assume the tumor is the largest blob, so extract it
%binaryTumorImage = bwareafilt(binaryImage, 1);
binaryTumorImage = bwareaopen(binaryImage, 100);
% Display the image.
subplot(2, 2, 2);
imshow(binaryTumorImage, []);
axis on;
caption = sprintf('Tumor Alone (binary mask)');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
%%%%%%%%%%%
% Find tumor boundaries.
% bwboundaries() returns a cell array, where each cell contains the row/column coordinates for an object in the image.
% Plot the borders of the tumor over the original grayscale image using the coordinates returned by bwboundaries.
subplot(2, 2, 3);
imshow(grayImage, []);
axis on;
caption = sprintf('Tumor\nOutlined in red in the overlay');
title(caption, 'FontSize', fontSize,'Interpreter', 'None');
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
hold on;
boundaries = bwboundaries(binaryTumorImage);
numberOfBoundaries = size(boundaries, 1);
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k};
% Note: since array is row, column not x,y to get the x you need to use the second column of thisBoundary.
plot(thisBoundary(:,2), thisBoundary(:,1), 'r', 'LineWidth', 2);
end
hold off;
% Extract the gray scale tumors alone
tumorOnlyImage = grayImage; % Initialize
% Erase everything except the tumors
tumorOnlyImage(~binaryTumorImage) = 0;
subplot(2, 2, 4);
imshow(tumorOnlyImage, []);
axis on;
caption = sprintf('Tumor only (gray scale image)');
title(caption, 'FontSize', fontSize,'Interpreter', 'None');
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
marwa za
2017년 11월 22일
please can you suggest me another example for the segmentation of brain lesions
Image Analyst
2017년 11월 22일
marwa za
2017년 11월 22일
thanks, I am looking for another method (uncomplicated) just to do a comparative study
Image Analyst
2017년 11월 22일
Well good luck. It generally can't get any more uncomplicated than thresholding. Please take the time to understand each step and then it won't seem so complicated.
marwa za
2017년 12월 1일
I applied the thresholding method on another image but it does not give a good result !! Can you help me
Image Analyst
2017년 12월 2일
marwa za
2017년 12월 2일
the thresholding is not complicated but unfortunately it does not give a good result with other images
Image Analyst
2017년 12월 2일
That's why you need to use more sophisticated, and complicated, algorithms.
참고 항목
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)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)