Category Archives: Home

[Solution] warning C4305: ‘initializing’ : truncation from ‘double’ to ‘float’

VC++ Compiler throws warning C4305: ‘initializing’ : truncation from ‘double’ to ‘float’ warning when we try to declare float variable as double.

Remember

float M_PI = 3.1428571428571428     // This is actually double variable

will throw the warning: warning C4305: ‘initializing’ : truncation from ‘double’ to ‘float’

The right way to do declare float varible is

float M_PI = 3.1428571428571428f       //Right way to declare float variable

We only added a f at the end of the value.

This is our solution to the above problem :: warning C4305: ‘initializing’ : truncation from ‘double’ to ‘const float’

[How To] Reset Firefox Master Password

I recenlty forgot my firefox Master password and searched for process to recover/reset the master password and found this solution to reset it.

Note: Upon resetting, you will lose all the stored information in the Password Manager, as this is a built-in security feature to prevent people from simply resetting your Master Password to gain access to your passwords.

In the firefox Addressbar
Type

chrome://pippki/content/resetpassword.xul

press the “Enter” key and click “Reset”.

Hope this helps someone.

Referenced From : ‘http://kb.mozillazine.org/Master_password

Image Preprocessing with ImageJ

ImageJ is a public domain Java image processing program inspired by NIH Image for the
Macintosh. It runs, either as an online applet or as a downloadable application, on any
computer with a Java 1.1 or later virtual machine. Downloadable distributions are available
for Windows, Mac OS, Mac OS X and Linux.

It can display, edit, analyze, process, save and print 8-bit, 16-bit and 32-bit images. It
can read many image formats including TIFF, GIF, JPEG, BMP, DICOM, FITS and “raw”.
It supports “stacks”, a series of images that share a single window. It is multithreaded, so
time-consuming operations such as image file reading can be performed in parallel with other
operations.

Today, I will show here some of the features of ImageJ that is widely used in preprocessing for Image Processing.

1. Color Image to GrayScale Image

Open Color Image (File > Open > Select any colorful image then hit Open)

See the Image Below

Sample Color Image

Sample Color Image

To Convert to GrayScale
Image > type > 8 bit

See the Image Below

Sample Grayscale Image

Sample Grayscale Image

2. Change the Image to Binary
Process > Binary > Make Binary

Sample Binary Image

Sample Binary Image

Now to remove the noise I use Median filter, radius set at 10.0 pixel.
Process > Filters > Median
I set here radius to 10 that removes the most of the noise for my image.
See the image Below

Noise Reduced Image

Noise Reduced Image

Most of the Noise are reduced.

Now further cropping of the image can be done by the use of various cropping techniques.

We conclude our work here, we just saw how ImageJ can be used to analysis various techniques for image processing quicky and see the results that best suit to us.

Rather than converting image directly to Binary Image we could have used the appropriate thresholding value to get the suitable threshold value that suit to our image processing need, which can be done by

Image > Adjust > Threshold

(Scroll the horizontal scroller to the appropriate settings)

Hope you got some basic idea on using ImageJ for Image Analysis.

[How To] Custom Checkbox using jQuery

Here is how I managed to get the custom checkbox using jQuery. See the screenshot below

JQuery Custom CheckBox

JQuery Custom CheckBox

The simple idea is to put class where we want to display checkbox. Here I have used two classes .clear and .checked. The name are very obvious.

.clear holds the unchecked state of checkbox.

.checked holds the checked state of checkbox.

Whenever the click on the class .clear and .checked class is triggered, we change the background accordingly by adding and removing the corresponding CSS by jQuery, this is where we use jQuery in fact.

We have three files:

1. checkbox.html
2. checkbox.js
3. checkbox.css

Source code for checkbox.html

<html>
<head>
<title>JQuery Custom gnu CheckBox Demo</title>
<link rel="stylesheet" href="checkbox.css">
<script type="text/javascript" src="jquery-latest.pack.js"></script>
<script type="text/javascript" src="custom_checkbox.js"></script>
</head>
<body>
<h3>Show More Tutorials on :</h3>
		<ul id='langauges'>
			<li><p><span class='clear' rel='java'></span>Java</p></li>

			<li><p><span class='clear' rel='visual basic'></span>Visual Basic</p></li>
			<li><p><span class='clear' rel='python'></span>Python</p></li>
			<li><p><span class='clear' rel='ruby'></span>Ruby</p></li>
			<li><p><span class='clear' rel='c/c++'></span>C/C++</p></li>
		</ul>

	<p class='show_value'></p>

</body>
</html>

Sourcecode for custom_checkbox.js

$(document).ready(function() {
	var opt = $('p &gt; span');
	$(opt).click(function() {
		var value = $(this).attr('rel');

		if ($(this).hasClass('clear')) {
			$(this).removeClass('clear');
			$(this).addClass('checked');
			$('.show_value').text("Checked : "+value);
		} else {
			$(this).removeClass('checked');
			$(this).addClass('clear');
			$('.show_value').text("Unchecked : "+value);
		}
	});
});

Sourcecode for checkbox.css

body {
	background:#000;
	color:#fff;
}
ul#langauges {
	list-style:none;
	width:80%;
}
ul#langauges li {
	width:70%;
}

span.checked {
	background-image:url('checked.png');
	background-repeat:no-repeat;
	background-position:50% 50%;
}

span.clear {
	background-image:url('clear.png');
	background-repeat:no-repeat;
	background-position:50% 50%;
	}

.clear,.checked {
	float:left;
	margin-right:5px;
	display:block;
	background-image:url('clear.png');
	background-repeat:no-repeat;
	background-position:50% 50%;
	width:22px;
	height:22px;
}

That’s all, try and enjoy it.