Sie sind auf Seite 1von 14

Fire alarm using thermistor & NE555Control structures form the basic entities of a

“structured programming language“. We all know languages like C/C++ or Java are all
structured programming languages. Control structures are used to alter the flow of
execution of the program. Why do we need to alter the program flow ? The reason is
“decision making“! In life, we may be given with a set of option like doing “Electronics” or
“Computer science”. We do make a decision by analyzing certain conditions (like...
READ MORE

Quick Sorting algorithm with example code


in C/C++/Java languages
jojo September 18, 2012 No Comments

We have seen 3 simple sorting algorithms already 1) Bubble Sorting 2) Selection


Sorting and finally Insertion sorting. All these algorithms were so simple to understand
and were easy to implement as a program in C/C++ or even Java. But at the same time
all 3 of them were too inefficient. Their execution time was of the order of n*n, where n
is the number of elements to be sorted. In practice, these simple sorting algorithms are
seldom used. ...
READ MORE

Insertion sorting algorithm with example in


C/C++/Java languages
jojo September 17, 2012 No Comments

So far we have seen 2 sorting algorithms:- 1) Bubble sorting and 2) Selection sorting.
Now in this article, we are analyzing insertion sort algorithm with its example code
suitable for C/C++/Java programming languages. I recommend you go through above
articles of Bubble sorting and Selection sorting before reading further. Insertion sorting
algorithm sorts one element at a time. It begins by sorting the first 2 elements in order.
In the next step, it takes the third element and compares it...
READ MORE
Selection Sort in C/C++/Java programming
languages
jojo September 17, 2012 No Comments

In the previous article, we have analysed Bubble sort algorithm and it’s implementation
in C programs. In this article we are going to see another sorting algorithm, named,
Selection sorting. Just like “Bubble sort”, selection sort is also considered as an
inefficient sorting algorithm. If you are curious to know the reason for this, please read
the article about Bubble sort carefully. The number of comparisons involved in an
average bubble sort is 0.5*(n*n-n). Same is the index for...
READ MORE

Difference between Procedure


Oriented(POP) and Object Oriented
Programming(OOP)
jojo September 14, 2012 8 Comments

We all know there exist 2 approaches to write a program – 1) Procedure oriented


programming (POP) and 2) Object oriented programming (OOP). You can write a
program in either way but there are notable differences between both approaches.
These 2 approaches are the result of software development evolution over many
decades. Since the invention of computer, many approaches and methods have been
tried to write a program. It includes methods like a) Top-Down programming b) Bottom-
Up programming c)...
READ MORE

Bubble Sorting with example in C/C++/Java


jojo September 17, 2012 6 Comments

Bubble sorting is one of the simplest sorting algorithm that we can use to sort an array
or a structure. Though it is so simple to implement in a C program, bubble sort is also
considered as an inefficient sorting algorithm. Bubble sort comes handy in cases where
the total number of elements to be sorted is so small (may be in the 100’s range). When
the data size is large/huge bubble sort is seldom used in practical programming world.
Let’s...
READ MORE

Void pointers in C
jojo July 26, 2012 8 Comments

In this article we are learning about “void pointers” in C language. Before going further it
will be good if you refresh about pointers by reading – Introduction to pointers in C. A
pointer variable is usually declared with the data type of the “content” that is to be stored
inside the memory location (to which the pointer variable points to). Ex:-
char *ptr; int *ptr; float *ptr; A pointer variable declared using a...
READ MORE

Introduction to pointers in C
jojo July 25, 2012 9 Comments

The basic purpose of developing a C programming tutorial for this website –


CircuitsToday – is to make it useful for people who wish to work with embedded
systems. Really good C programming skill is an essential to work with embedded
systems and “Pointers” is the most important concept in C that should be mastered by
an embedded systems programmer. “Pointers” are so important because it enables a
programmer to work directly with memory of the system. Memory of...
READ MORE

Compilers vs Interpreters – An overview of


the differences
jojo July 19, 2012 5 Comments

It is a general notion that people try to classify programming languages as either


“compiled” language or “interpreted” language. Even experienced programmers tend to
get confused here! But the fact is, programming languages are neither “compiled” nor
“interpreted” types. They can be both at the same time. Compiling or interpreting -both
are 2 different ways of implementing the same program written using a programming
language. A program written in C language can either be compiled or can be
interpreted....
READ MORE

How to use Turbo C/C++ to run your first C


program
jojo July 18, 2012 20 Comments

There is no one in this world who is born as a programmer To write efficient


programs using any languages you have to learn it by doing! You have to write as many
different programs using as many different algorithms. You have to break codes, make
errors, debug errors and sometimes you have to approach the same problem using 2 or
3 different logics. To learn “C language” efficiently, you must write a lot of different C
programs...
READ MORE

 1
 2

Page 1 of 2
SORT BY TYPE

 101-Announcements(28)

 555 Timer IC(16)

 8051(26)

 8051 projects(21)

 Amplifier Circuits(39)

 Arduino(70)

 ARM(3)

 Audio Circuits(104)

 Automotive Circuits(28)

 AVR(23)
 Basic Electricity(1)

 Basic Electronics(17)

 Battery Circuits(23)

 C plus plus(7)

 C Programming(14)

 Cable TV Circuits(1)

 Camera Technology(5)

 Clipping and Clamping Circuits(7)

 Clocking & Timer Circuits(2)

 Conversion Circuits(10)

 Counter Circuits(2)

 Counters(2)

 Digital Electronics(11)

 Drones(1)

 Education & Training(7)

 Electronic Components(31)

 Electronic Keys & Locks(3)

 Electronics Books(10)

 Electronics Jobs(5)

 Embedded Systems(7)

 Equipment Reviews(1)

 Events(3)

 Fan Circuits(1)

 Filter Circuits(16)

 Fire Alarm(3)

 Fun & Game Circuits(14)

 Gadget Reviews(6)

 Guides(15)

 Ham Radio Circuits(2)


 High Voltage Circuits(1)

 History(26)

 Home Circuits(35)

 Industrial Circuits(15)

 Industry News(1)

 Infographics(1)

 Instruments(13)

 Integrated Circuits(20)

 Inverters(5)

 Lab Manuals(20)

 LED related(3)

 Light Related(14)

 Lighting Circuits(44)

 MATLAB(3)

 Microcontrollers(12)

 Mobile Phone Related(3)

 Motor Related(14)

 Nanotechnology(14)

 Oscillators(25)

 PCB(2)

 Peripheral Interface Controller (PIC)(29)

 Power Controller Circuits(8)

 Power Electronics(3)

 Power Supplies(72)

 Product Reviews(12)

 Project Ideas(1)

 Projects(7)

 Proteus(16)

 Proximity Detectors(3)
 Radio Circuits(30)

 Radio Transmitters(19)

 Raspberry Pi(3)

 Relays(3)

 Remote Circuits(12)

 Reviews(8)

 Robotics(7)

 RTOS(2)

 Security & Saftey(17)

 Sensor Circuits(16)

 Signal Conditioners(11)

 Signal Generators(13)

 Speed Controller Circuits(1)

 State space analysis(2)

 Switching Circuits(6)

 Tech News(86)

 Telephone Related(9)

 Television Related(4)

 Temperature Related(3)

 Test & Measurement Circuits(38)

 Testing Components(9)

 Three phase circuits(1)

 Timer Circuits(3)

 Tone generator circuits(20)

 Tools and Softwares(6)

 Transmitters(7)

 Tutorials(163)

 UPS(2)

 USB Circuits(3)
 Videos(5)

 VLSI(36)

 Voltage Regulators(15)

OTHER LINKS

 About

 Advertise With Us

 Authors

 Datasheets

 Disclaimer

 Electronic Circuit Symbols

 Electronic Project Kits

 Lab Manuals

o Electronic Circuits Lab

o Microcontroller lab

o Microprocessor Lab

 Privacy Policy

 Resistor Color Code Calculator

 Testing Components

 Write For Us
PCBFOX
PCB Manufacturers

POPULAR TAGS
2N2222 555 IC 555 timer 8085 lab manual arduino circuits Audio Amplifier Circuits Audio
circuits circuit design circuit diagramDigital
Electronics Electronic Circuits Electronic Components Electronic
Instruments Electronic Projects Filter Circuits FM transmitter History of Electronics hobby
circuits hobby projects Home Circuits IC IC Audio Amplifier Integrated
Circuits Invention Stories Light Related microprocessor lab manual Most Popular
Circuits Nanotechnology NE555 timer Oscillators PIC PLL Power Amplifiers Power
Supplies Radio Circuits Robotics SCR Simple Electronic Projects-List of Simple
projects for beginners Tech News Thyristors Timer
IC Tutorials VLSI voltage converter Voltage Regulators
Image Representation in MATLAB – How to Represent Binary,Grayscale & Color Images

Avaneet Ranjan October 23, 2013 1 Comment

In this article, we are going to talk about images, their types and some basic functions for Images. This
article is part of our MATLAB tutorial series, which we are developing for Image processing through
MATLAB. We expect you to give us feedback, so that we can keep the information flow more efficient,
informative and up to the mark. In the first chapter, you have learned an introduction to MATLAB and its
commands. In this chapter you will learn how to represent different types of images in MATLAB. In
addition you will learn how to read & display images in MATLAB and how to create an M file.

Taking Up Images

Technically whatever we categorize as a picture, is an Image. We already talked about the basics of
Image processing in our first article, we would focus today on technical representation of images.

Different Types of Images

Binary Image: An image that consists of only black and white pixels. Technically these types of images
are called as Black and White Image. (Although it makes me sad to break my reader’s heart but till now
what you called black and white images have some other technical name).

Grayscale Image: In daily language what we refer to as black-and-white (as in old photos) are
actually grayscale. It contains intensity values ranging from a minimum (depicting absolute black) to a
maximum (depicting absolute white) and in between varying shades of gray. Typically, this range is
between 0 and 255.

Color Image: We all have seen this! Such an image is composed of the three primary colors, Red, Green
and Blue, hence also called an RGB image.

How to represent binary image in MATLAB

Binary Image

How to represent grayscale image in MATLAB

Grayscale Image

How to represent color image in MATLAB

Color Image

RGB value: All colors which we see around us can be made by adding red, blue and green
components in varying proportions. Hence, any color of the world can uniquely be described by its RGB
value, which stands for Red, Blue and Green values. This triplet has each value ranging from 0 to 255,
with 0 obviously meaning no component of that particular color and 255 meaning full component.
For example, pure red color has RGB value [255 0 0], pure white has [255 255 255], pure black has [0 0
0] and has RGB value [55 162 170].

Representation of an Image in MATLAB

An image in MATLAB is stored as a 2D matrix (of size mxn) where each element of the matrix
represents the intensity of light/color of that particular pixel. Hence, for a binary image, the value of
each element of the matrix is either 0 or 1 and for a grayscale image each value lies between 0 and 255.
A color image is stored as an mxnx3 matrix where each element is the RGB value of that particular pixel
(hence it’s a 3D matrix). You can consider it as three 2D matrices for red, green and blue intensities.

Reading and Displaying Images

imread(): To read an image and store in a matrix.


Syntax: IM=imread(‘filename’)

where IM is a matrix. If the file is in the current directory (as described above), then you only need to
write the filename, else you need to write the complete path. Filename should be with extension (.jpg,
.bmp,..). There are some default images of MATLAB like ‘peppers.png’, ‘cameraman.tif’, etc. You can try
reading them as

>>im=imread(‘peppers.png’);

It is always advised to use a semi-colon (;) at the end of the statement of reading an image,
otherwise… you can try yourself what happens!

imshow(): Displays the image. Syntax:

imshow(‘filename’)

or imshow(im)

Example:-

>>imshow(‘cameraman.tif’);

OK, now let’s make our own image, try this:

>>a(1,1)=0;
>>for i=1:200; for j=1:200

a(i+1,j+1)=1-a(i,j);

end end

>>imshow(a);

You try out making many different types of images like this just to make yourself comfortable with the
commands learnt till now.

Data cursor: To see the values of the colors in the figure window, go to Tools>Data Cursor (or select
from the toolbar), and click over any point in the image. You can see the RGB values of the pixel at
location (X,Y).

Image representation in MATLAB

A better option of data cursor is the function imtool(). Type the following

>>imtool(‘peppers.png’);

And see the pixel info on lower left corner as you move mouse pointer over different pixels.

Now, before we move on to our next article, we take a little detour in this article and talk about some
MATLAB resources which will be extensively be used in coming article.

Making M Files & Functions in MATLAB

It is a provision in MATLAB where you can execute multiple commands using a single statement. Here
the group of commands is stored as a MATLAB file (extension .m).
M Files in MATLAB - How to create & save an M File in Matlab

Here we have saved the m-file by the name “test.m”. Now as you type

>>test

And in MATLAB command window, all the above commands will execute.

Comments: As we have comments in C/C++/ Java using double slash (//), in MATLAB we use symbol %
to write comments, i.e., statements that are not considered for execution. You can see comments
in green in the snapshot above.With the invention of Logic gates, we can design electronic circuits that
can simply work as a calculator to high end devices that can be even used for scientific purposes. Earlier
only humans could add and subtract numbers. But with the applications of Boolean gates like Adders,
Subtractors, Counters and so on it is possible to create almost any logic.

With this post, we are going to help you and thus understand better, the logic behind using gates. The
steps are simple and creative. But for the implementation requires a relay and a 6 volt battery. The very
first implementation of Boolean gates also included relays. But the technology has gone far beyond that
they have been replaced by sub-microscopic transistors etched onto silicon chips. Relays consume some
amount of power, and they are bigger in size. But the transistors used these days are microscopic and
are faster than relays. They also consume very less power when compared to a relay.

But you will get a clear idea about the working by using relays. They are also practically very simple to
use. All you need to know is know the basics of gates and their truth table. Enter the input values and
take the output values.

To know more about setting up a relay, and it’s working take a look at this link.

TAKE A LOOK : WORKING OF RELAYS

As we know there are only two states for a Gate – a HIGH state and a LOW state. In a relay, these states
will be represented by two voltages. The HIGH state is represented by 6 volts and the LOW state to be 0
volts. A 6 volt battery is required to power up the circuit.
NOT Gate

Take a look at the picture below to get a clear idea on how a NOT Gate is implemented. From the circuit
it is clear that when you apply 6 volts to A, you get 0 volts in Q and when you apply 0 volts to A you get 6
volts in Q.

NOT GATE Implementation

NOT GATE Implementation

AND Gate

As an AND bit requires a minimum of 2 inputs, two relays will be needed. The figure is shown below.

AND GATE Implementation

AND GATE Implementation

From the figure it is clear that if 6 volts it applied to both A and B, you get the output Q=6 volts. For any
other combination of A and B, the output will be 0 volts. The same circuit can be changed into an OR
Gate by hooking two wires for A and B together. You can also use two relays in parallel.

You can also make the circuit fancier by reading the outputs on bulbs. That is, when a HIGH state occurs,
LIGHT = ON. When a LOW state occurs, LIGHT = OFF.

Thus the three basic Gates NOT, AND and OR can be implemented easily.

With the help of the basics above you can easily implement 8-bit ripple carry adders and so on. All these
basics are also the basics for the working of computers.

Das könnte Ihnen auch gefallen