How to generate a bitmap image without using function...Please help
Ältere Kommentare anzeigen
How can i generate bitmap representation of an image using thresholding?? below code didn't work....
for i=1:r
for j=1:s
thresh=C(i,j)+Di;
if(imean(i,j)>=thresh)
bm(i,j)=1;
else
bm(i,j)=0;
end
end
end
figure
imshow(bm);
8 Kommentare
Sreeda M A
am 29 Jun. 2016
Bearbeitet: Geoff Hayes
am 29 Jun. 2016
Geoff Hayes
am 29 Jun. 2016
Sreeda - how are r and s initialized? You are trying to iterate over C which is a 1x256 matrix yet r is at least two. Please clarify where these values have come from and how they relate to C.
Sreeda M A
am 4 Jul. 2016
Stephen23
am 4 Jul. 2016
@Sreeda M A: Don't waste your time writing loops. MATLAB is a high-level language, so you don't need to mess around with ugly loops. See Walter Roberson's answer for the simplest and fastest solution.
Walter Roberson
am 4 Jul. 2016
If r and s are the size of your image, then your image is stored in some variable other than C.
Sreeda M A
am 4 Jul. 2016
Bearbeitet: Image Analyst
am 4 Jul. 2016
Image Analyst
am 4 Jul. 2016
Bearbeitet: Image Analyst
am 4 Jul. 2016
Also to do a locally adaptive threshold like you did, you can do it vectorized if you just create an m1 (or n1) image with conv2() or imfilter(), then use >=. Let me know if you can't figure it out.
bm =
Sreeda M A
am 10 Aug. 2016
Antworten (1)
Walter Roberson
am 29 Jun. 2016
thresh = C + Di;
bm = imean >= thresh;
No loop required.
Kategorien
Mehr zu Images finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!