Posts

Double The Size of an Image using Bi-linear Interpolation

Image
%================== Program to double the size of an Image ===================% A=imread('pic1.tif'); [M N]=size(A); B=uint8(zeros(2*M,2*N)); for i=1:M     for j=1:N         B(2*i-1,2*j-1)=A(i,j);         B(2*i,2*j-1)=A(i,j);         B(2*i-1,2*j)=A(i,j);         B(2*i,2*j)=A(i,j);     end end C=B; [M N]=size(B); mask=[0, 1, 0;1, 0, 1;0, 1, 0;]; const_mat=zeros(1,4); for i=1:M     for j=1:N         mat=zeros(1,4);         S=zeros(4,4);         m=1;         for x=1:3             for y=1:3                 if(((i+x-2)<M &&(j+y-2)<N)&&((i+x-2)>0 && (j+y-2)>0))                     if(mask(x,y))         ...

8 Bit Plane Slicing of an image in Image Processing

Image
%================ Bit Plane Slicing Program =================% A=imread('bit_plane_img.tif'); subplot(3,3,1),imshow(A),title('INPUT IMAGE'); for i=1:8     B=bitplaneslicing(A,i);     subplot(3,3,i+1),imshow(B),title(i); end %====================================================% %================ Bit Plane Slicing Function =================% function [ B ] = bitplaneslicing( A ,n) % function for n bit plane slicing where n<=8 [M,N]=size(A); B=zeros(M,N); for i = 1:M     for j = 1:N         str=dec2bin(A(i,j),8);         if strcmp(str(9-n),'0')             B(i,j)=0;         else             B(i,j)=2^(n-1);         end     end end end %====================================================% Input Image: bit_plane_img.tif Output Image:

Prisoner Dilemma Problem

Prisoner Dilemma Problem Cooperation is usually analyzed in game theory by means of a non-zero-sum game called the “Prisoner’s Dilemma”. The two players in the game can choose between two moves, either “cooperate” or “defect”. The idea is that each player gains when both cooperate, but if only one of them cooperates, the other one, who defects, will gain more. If both defect, both lose (or gain very little) but not as much as the “cheated” co-operator whose cooperation is not returned. The whole game situation and its different outcomes can be summarized by table below, where hypothetical “points” are given as an example of how the differences in result might be quantified. Payoff Matrix for Prisoner Dilemma Player 1 Player 2 Cooperate Defect Cooperate 3,3 5,0 Defect 0,5 1,1 Step1 : Initialization of 20 population each of 70 (64+6) Strings where six extra letters encode three previous...

BEST PROGRAM FOR STRING PALINDROME IN JAVA

/* The progrma will check whether a word is palindrome.  * BEST PROGRAM FOR STRIG PALINDROME IN JAVA */ package advance; import javax.swing.*; public class Palindrom {     public static boolean ispalindrom(String str) {         int i = 0, j = str.length();         while ((i < j) && (str.charAt(i++) != str.charAt(--j))) {             return false;         }         return true;     }     public static void main(String[] args) {         String str = JOptionPane.showInputDialog("Enter a string");         if(ispalindrom(str))             JOptionPane.showMessageDialog(null, str + " is a Palindrome String.");         else             JOptionPane.showMessageDialog(null, str + " is a not a Palindrome Str...

Conversion Of Big Number into Words(In Indian System).

package snlkjha; import java.util.*; import java.math.BigInteger; /**  * @author snlkjha  */ public class N2word {     public static String get(int n){         String[] x1={"","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thrteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Ninteen"};         String[] x2={"","Ten","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninty","Hundred"};         if(n<20) return x1[n];         else return x2[n/10]+" "+x1[n%10];     }       public static String convert_number_into_words(BigInteger n){       String message=" Only",x3[]={"",...

Program for finding Body Mass Index Using JAVA

/*  * BODY MASS INDEX  * It is a numeric indicator of human body fat based on a person weight and height.It is applicable to adult men  * and women and is mainy used to screen indivduals in order to detect potential weight problems.  * The common formulafor calculating BMI = Mass(Kg)/[height(m)]^2  * It was invented by Begian Scinetist Adolphe Quetelet and hence it is also known as the Quetelet Index.  * A BMI of 18.5 to 24.9 is considered normal.  */ package Snlkjha; import javax.swing.*; /**  * @author Snlkjha  */ public class BodyMassIndex {     public static void main(String[] args) {                 String wt = JOptionPane.showInputDialog("Enter Weight(In Kg):");         String ht = JOptionPane.showInputDialog("Enter Height(In Inch):");         double weight = Double.valueOf(wt).doubleValue();         double...

STRING PALINDROME USING STACK AND QUEUE

#include<stdio.h> #include<stdlib.h> #include<string.h> void push(char ); char pop(); void nq(char ); char dq(); typedef struct list {     char data;     struct list *next; }node; node *top=NULL,*front=NULL,*rear=NULL; int main() {     char word[20];     printf("Type the Word:");     scanf("%s",word);     int length=strlen(word),i=0;     while(word[i]!='\0')     {         push(word[i]);         nq(word[i]);         i++;     }     for(i=0;i<length;i++)     {         if(pop()!=dq())         break;             }     if(i==length)        ...