Why do I keep getting a black image when i dont use ?
18 views (last 30 days)
What is the difference between using  with imshow and dividing an image by a scalar before using imshow fxn?
Is my code wrong?
I am trying both methods and I need to describe the difference but I wanted to know if i did something wrong?
I can also adjust the filter. I tried to play around with it but I keep getting the black image in the dividing by 100 method
1. LoG filter
a) Read the image file ‘brain_whitenoise.jpg’ and store the image into ‘bw’ variable.
b) Make ‘LoG’ filter and store it into ‘f1’ variable. Try different parameter options(HSIZE and SIGMA) of 'log' filter and choose the best one from your observation.
c) Apply ‘f1’ filter to ‘bw’ and store the result into ‘cf1’ variable.
d) Make ‘Laplacian’ filter and store it into ‘f2’ variable. Try different parameter options(HSIZE and ALPHA) of 'log' filter and choose the best one from your observation.
e) Apply ‘f2’ filter to ‘bw’ and store the result into ‘cf2’ variable.
f) Display the variable 'bw', ‘cf1’ and ‘cf2’ within the same window. When you call imshow(), do not use '' parameter. Instead, before you display cf1 and cf2, divide both images by 100. Describe how the division by 100 affects the displayed images.
%% 1. LoG filter
bw=imread('brain_whitenoise.jpg'); %a)Read‘brain_whitenoise.jpg’;store into ‘bw’
f1=fspecial('log',[3 3],0.2); %b)Make ‘LoG’ filter store it into ‘f1’
Cf1=imfilter(bw,f1,'symmetric'); %c)Apply ‘f1’ filter to ‘bw’ store the result into ‘Cf1’
f2=fspecial('laplacian',0.3); %d)Make ‘Laplacian’ filter store it into ‘f2’ variable
Cf2=imfilter(bw,f2,'symmetric'); %e)Apply ‘f2’ filter to ‘bw’ and store the result into ‘Cf2’
%divide images by 100
subplot(3,2,1); %Display 'bw', ‘cf1’ and ‘cf2’ within the same window using  to compare
subplot(3,2,2); %f) Display 'bw', ‘cf1’ and ‘cf2’ within the same window after images/100
%Describe how the division by 100 affects the displayed images
%dividing the image difficult to see compared to 
Image Analyst on 6 Oct 2021
If you have a floating point image, it expects all the values to be within the 0-1 range. If it's in that range, it will display 0 as 0 and 1 as 255. Numbers below 0 will show up as black. Numbers above 1 will show up as white.
If you use , it can take floating point numbers in any range and will display the min value as 0 and the max value as 255, and values in between will be linearly scaled in brightness.
If your display is still black even though your numbers are in the 0-1 range, it's possible all your numbers are like 0.1 or less. So a value of 0.1 will show up as gray level 25 - really dark. Lower values will also be very very dark and hard to see. If you use  then it will map the 0.1 to 255 and values in the range 0-0.1 will be linearly scaled between 0 and 255.
If your image is in the range 0-255, then you divide by 100 then your values go from 0 to 2.55. Anything 0-1 will show up in gray scale, and anything between 1.00 and 2.55 will be saturated -- clipped to 255 and appear totally white.