필터 지우기
필터 지우기

HI to all.. this is about thresholding the image ..

조회 수: 1 (최근 30일)
vishnu
vishnu 2012년 1월 11일
i am doing with thresholding a image ,i have an image .. for examble
256*256 = 65536 co efficients .. out of that i want to select
65536/4 =16384
with largest absolute values ..
please some body help

채택된 답변

Chandra Kurniawan
Chandra Kurniawan 2012년 1월 11일
Hi,
I have small example for 4x4 matrix.
I = round(10*rand(4,4))
J = zeros(size(I,1), size(I,2));
coeff = numel(I)/4;
[B IX] = sort(I(:),'descend');
J(IX(1:coeff)) = 1
The idea is sort the matrix and then select 4 largest element.
See the result below :
I =
7 8 3 7
1 7 7 5
7 9 2 5
5 9 0 9
J =
0 1 0 0
0 0 0 0
0 1 0 0
0 1 0 1
To apply this to image, just use the same way :
I = imread('cameraman.tif');
J = zeros(size(I,1), size(I,2));
coeff = numel(I)/4;
[B IX] = sort(I(:),'descend');
J(IX(1:coeff)) = 255;
imshow(uint8(J));
But, I think it takes a long time
  댓글 수: 4
Chandra Kurniawan
Chandra Kurniawan 2012년 1월 11일
to verify just
length(find(J));
vishnu
vishnu 2012년 1월 11일
thank you

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

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by