Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
vishnu
vishnu am 11 Jan. 2012
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

Akzeptierte Antwort

Chandra Kurniawan
Chandra Kurniawan am 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 Kommentare
Chandra Kurniawan
Chandra Kurniawan am 11 Jan. 2012
to verify just
length(find(J));
vishnu
vishnu am 11 Jan. 2012
thank you

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by