HI to all.. this is about thresholding the image ..
1 view (last 30 days)
Show older comments
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
Accepted Answer
Chandra Kurniawan
on 11 Jan 2012
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 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!