How to apply a rectangular window on an image?

Hello, I want to scan a dicom picture with a rectangular window. I do not know how to apply the window. Also I want to know if my codes are correct for making a rectangular or not. These are my codes :
w=sigwin.rectwin; winwrite(w);
I guess it will create window by length 64. how can I change the length and width of my window?
Thanks

 채택된 답변

Image Analyst
Image Analyst 2014년 1월 10일
편집: Image Analyst 2014년 1월 10일

0 개 추천

Use conv2() or imfilter():
windowWidth = 63; % Should be an odd number!
windowHeight = 33; % Should be an odd number!
% Make uniform window which will take average and make it blurry.
kernel = ones(windowHeight, windowWidth ) / windowHeight * windowWidth;
output = conv2(grayImage, kernel, 'same');
% or
output = imfilter(grayImage, kernel);

댓글 수: 4

Faranak
Faranak 2014년 1월 10일
This code makes something like noise on image,I want to open a rectangular window and apply it to scan over my image,I want it to detect and count the number of nonzero pixel in that rectangular window on the image.
Then do this:
windowWidth = 63; % Should be an odd number!
windowHeight = 33; % Should be an odd number!
% Make uniform window which will take the sum in the window.
kernel = ones(windowHeight, windowWidth );
output = conv2(grayImage, kernel, 'same');
% or
output = imfilter(grayImage ~= 0, kernel);
output pixel is the sum of all non-zero pixels within the window centered over that output pixel.
Faranak
Faranak 2014년 1월 13일
I tried your code but it is not what I want. In the picture attached you can see a dicom image of breast and also a small rectangular window on the image.I want this. A small rectangular window on the image which is scanning breast and detect and counts the number of nonzero pixels. Thank you for your help.
Image Analyst
Image Analyst 2014년 1월 13일
편집: Image Analyst 2014년 1월 13일
There are no non-zero pixels in that image. If you want to count all pixels darker than some threshold value then you can binarize the image first
thresholdValue = 50; % or whatever...
binaryImage = grayImage < thresholdValue;
output = conv2(binaryImage, kernel, 'same');

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 DICOM Format에 대해 자세히 알아보기

질문:

2014년 1월 10일

편집:

2014년 1월 13일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by