हिस्टोग्राम्स
हिस्टोग्राम्स किसी इमेज में मानों के वितरण को दिखाते हैं। ये हर एलिमेंट को उसकी intensity के आधार पर बिन में रखते हैं और हर बिन का आकार मापते हैं.
हिस्टोग्राम के नीचे के क्षेत्र को cumulative distribution function कहा जाता है। यह बताता है कि दिए गए पिक्सेल-इंटेंसिटी रेंज कितनी बार आती है.
इस अभ्यास में, im की intensity distribution का वर्णन कीजिए: हिस्टोग्राम और cumulative distribution function निकालिए और उन्हें साथ में दिखाइए.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में बायोमेडिकल इमेज विश्लेषण
अभ्यास निर्देश
scipy.ndimageकोndiनाम से import कीजिए.imका 256-बिन हिस्टोग्राम जनरेट कीजिए जोnp.uint8मानों की पूरी रेंज कवर करे.imके लिए cumulative distribution function निकालिए। पहलेhistका cumulative sum लें, फिरhistमें कुल पिक्सेलों की संख्या से भाग दें.histऔरcdfको अलग-अलग subplots पर plot कीजिए। यह आपके लिए पहले से किया गया है.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Import SciPy's "ndimage" module
import ____ as ____
# Create a histogram, binned at each possible value
hist = ____
# Create a cumulative distribution function
cdf = hist.cumsum() / ____
# Plot the histogram and CDF
fig, axes = plt.subplots(2, 1, sharex=True)
axes[0].plot(hist, label='Histogram')
axes[1].plot(cdf, label='CDF')
format_and_render_plot()