Note that there are some explanatory texts on larger screens.

plurals
  1. POcontrast enhancement of an image using neighbourhoood
    primarykey
    data
    text
    <p>Hi I want to enhance the contrast of an image using the neighbourhood pixel values.</p> <p>Let the image be considered as u0. Then I want to enhance the image by using the formula</p> <p><img src="https://i.stack.imgur.com/pAjmq.png" alt="enter image description here"></p> <p>Here, M1 is the minima and M2 is the maxima of u0 among the neighbourhood pixels, Mg is the maximum gray level value of the original image. The neighbourhood taken for my operation is 9X9. uN is the new generated image (contrast enhanced image). </p> <p>I have tried out the following code but am not sure whether I am correct or not.</p> <pre><code>%Generate a contrast enhanced image tic clear all; close all; I = imread('4.jpg'); I = imresize(I,[128 128]); if size(I,3)== 3 P = rgb2gray(uint8(I)); P = double(P); elseif size(I,3) == 2 P = 0.5.*(double(I(:,:,1))+double(I(:,:,2))); else P = double(I); end ssize=9; mg=max(P(:)); f1 = @(x) min(x(:)); m1 = nlfilter(P,[9 9],f1); f2 = @(x) max(x(:)); m2 = nlfilter(P,[9 9],f2); P_op=((P-m1)./(m2-m1)).*mg; subplot(2,1,1),imagesc(P,[0 255]);colormap(gray);axis off; subplot(2,1,2),imagesc(P_op,[0 255]);colormap(gray);axis off; toc </code></pre> <p>Some of the results that I got are being shown below:</p> <p><img src="https://i.stack.imgur.com/FhVXA.png" alt="enter image description here"><img src="https://i.stack.imgur.com/WttmZ.png" alt="enter image description here"><img src="https://i.stack.imgur.com/Me0JL.png" alt="enter image description here"><img src="https://i.stack.imgur.com/eDGMT.png" alt="enter image description here"></p> <p>Can anyone please check and tell me whether my code is correct or not? I am not so sure myself. Also please tell me whether there is a better way of doing this. Thanks in advance guys.</p> <p><strong>EDITED question</strong> I re-read the work and I **have to apply the sliding window function to only a few specified pixels. **</p> <p>The pixels that I have to apply on is found out in this method. The initial contour of the image is detected (shown on the images in red). Then a band around the contour is drawn at a specified distance. <strong>The sliding window function has to be applied only on those pixels within the narrowband for the original images</strong></p> <p>I am giving the images, and the initial contours and the band images. </p> <p><img src="https://i.stack.imgur.com/hJDU2.png" alt="enter image description here"><img src="https://i.stack.imgur.com/rG8W9.png" alt="enter image description here"><img src="https://i.stack.imgur.com/aY3og.png" alt="enter image description here"><img src="https://i.stack.imgur.com/ISFEQ.png" alt="enter image description here"></p> <p>The pixels marked in white are <strong>my specified pixels on which the sliding function has to be applied</strong>. Can nfilter be applied on such criteria ? Please help. I will clarify further if my question is not correct. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload