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

1 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by