| Author |
Message |
baij
Joined: 08 Dec 2007 Posts: 3
|
05 Jun 2008 6:57 How to add fog to a image by Matlab |
|
|
|
| How to add the fog to a image or make the image like covered by fog (Matlab) ?. Please help me and send me the code. Thanks a lot.
|
|
| Back to top |
|
 |
xulfee
Joined: 27 May 2008 Posts: 205 Helped: 25 Location: Pakistan
|
11 Jun 2008 5:26 How to add fog to a image by Matlab |
|
|
|
| do u want to blure ur image?if yes then just do low pass filtering with image,other wise some noise functions are available in matlab see their documentation
|
|
| Back to top |
|
 |
echo47
Joined: 07 Apr 2002 Posts: 4205 Helped: 564
|
11 Jun 2008 5:52 How to add fog to a image by Matlab |
|
|
|
Are you talking about distance fog, like this?
http://en.wikipedia.org/wiki/Image:CGfog.jpg
Fog is basically a decrease in contrast or linear blending with a solid color such as blue-gray, but the amount of blending varies according to the distance to the objects in the scene. That's not something you can easily do without depth info.
|
|
| Back to top |
|
 |
baij
Joined: 08 Dec 2007 Posts: 3
|
28 Jun 2008 11:09 Re: How to add fog to a image by Matlab |
|
|
|
Thanks. Here my code
| Code: |
function im=FogEffect(i)
a = imadjust(i,[0.1 0.1 0.1; 1 1 1],[0 0 0; 1 1 1]);
[m,n,d] = size(i);
for w = 1:3
for u = 1:m
for v = 1:n
if mod(v+u,2) == 0
a(u,v,w) = 225;
end
end
end
end
h = fspecial('gaussian',10,1);
im = imfilter(a,h);
end |
and result
After
But it's not really real fog. Some one can help me develop this code. Thanks for your help.
|
|
| Back to top |
|
 |
echo47
Joined: 07 Apr 2002 Posts: 4205 Helped: 564
|
28 Jun 2008 11:26 How to add fog to a image by Matlab |
|
|
|
| What effect you are trying to achieve?
|
|
| Back to top |
|
 |
baij
Joined: 08 Dec 2007 Posts: 3
|
28 Jun 2008 11:34 Re: How to add fog to a image by Matlab |
|
|
|
| In some case, when the objects are near or far. My code can not make the real fog in the image.
|
|
| Back to top |
|
 |
echo47
Joined: 07 Apr 2002 Posts: 4205 Helped: 564
|
28 Jun 2008 11:36 How to add fog to a image by Matlab |
|
|
|
A JPEG image doesn't contain any depth information.
MATLAB can't guess the object distances.
Maybe you could manually paint fog onto the image by using something like Photoshop.
|
|
| Back to top |
|
 |