; Name: Arpan Chavda ; Roll No.:09BCE006 ; Aim: Enter string from user and convert upper case to lower case and ; vice versa without change in entered number in string. ;it runs on tasm assembler read macro str1 mov ah,0ah lea dx,str1 int 21H endm disp macro str mov ah,09h lea dx,str int 21h endm data segment str1 db 20 db 0 db 20 dup('$') msg1 db "Enter the String : $" msg2 db "Coverted string is:$" nl db 0dH,0AH,'$' data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax disp msg1 read str1 lea si,str1 inc si mov cx,[si] dec cx lp1: inc si mov al,[si] cmp al,39H jc skip mov al,[si] cmp al,5aH jnc subt mov al,[si] add al,20H mov [si],al jmp skip subt: mov al,[si] sub al,20H mov [si],al skip: loop lp1 disp nl disp msg2 disp nl disp str1+2 mov ah,4ch int 21h code ends end start Output: D:\BORLANDC\BIN>tasm str.asm Turbo Assembler Version 3.1 Copyright (c) 1988, 1992 Borland International Assembling file: string.asm Error messages: None Warning messages: None Passes: 1 Remaining memory: 459k D:\BORLANDC\BIN>tlink str.obj Turbo Link Version 5.1 Copyright (c) 1992 Borland International Warning: No stack D:\BORLANDC\BIN>str.exe Enter the String : as99DDF Converted string is: AS99ddf
Saturday, September 8, 2012
[Assembley Code]How to convert upper case to lower case and vice versa
[PROLOG] How to insert an element in list?
%program to insert an element in list domains A=symbol *. predicates addsym(A,symbol,integer,A). clauses addsym([],S,N,Q):- N<>0. addsym(P,S,N,[S|Q]):- N=0,!, addsym(P,S,-1,Q), write("inserted"). addsym([H|T],S,N,[H|Q]):- B=N-1, addsym(T,S,B,Q), write("ins").
[C-CODE] TCP Implementation in C
/*----------------------------tcp_client.c----------------------------------------*/
#include<stdio.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<string.h>
#define LOCAL_PORT 1500
#define SIZE 20
int main()
{
int sd,cd,len;
char buff1[SIZE],buff[SIZE];
struct sockaddr_in server,client;
sd = socket(AF_INET,SOCK_STREAM,0);
client.sin_family = AF_INET;
client.sin_port = htons(LOCAL_PORT);
client.sin_addr.s_addr = inet_addr("127.0.0.1");
bind(sd,(struct sockaddr *)&client,sizeof(client));
server.sin_family = AF_INET;
server.sin_port = htons(LOCAL_PORT);
server.sin_addr.s_addr = inet_addr("127.0.0.1");
connect(sd,(struct sockaddr *)&server,sizeof(server));
while(1)
{
/*Sending to server*/
printf("Enter the data:");
scanf("%s",buff1);
printf("Data:-%s",buff1);
write(sd,buff1,20);
printf("\n");
/*Receiving from server*/
read(cd,buff,20);
printf("Data:- %s\n",buff);
}
close(sd);
return 0;
}
/*----------------------------tcp_server.c----------------------------------------*/
#include<stdio.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#define LOCAL_PORT 1500
int main()
{
int sd,cd,buff[20],cliLen;
char buff1[20];
struct sockaddr_in server,client;
sd = socket(AF_INET,SOCK_STREAM,0);
server.sin_family = AF_INET;
server.sin_port = htons(LOCAL_PORT);
server.sin_addr.s_addr = inet_addr("127.0.0.1");
bind(sd,(struct sockaddr *)&server,sizeof(server));
listen(sd,5);
cliLen = sizeof(client);
cd = accept(sd,(struct sockaddr *)&client,&cliLen);
while(1)
{
/*Receiving from client*/
read(cd,buff,20);
printf("Data:- %s\n",buff);
/*Sending to client*/
printf("Enter the data:");
scanf("%s",buff1);
// printf("Data:-%s",buff1);
write(cd,buff1,20);
printf("\n");
}
close(cd);
close(sd);
return 0;
}
[MATLAB] Histogram Matching program
final_img=imread('fig3.jpg');
input_img=imread('fig3.jpg');
ref_img=imread('fig3.jpg');
[m n]=size(input_img);
mn=m*n;
pdf_main=zeros(1,256);
pdf_ref=zeros(1,256);
cdf_main=zeros(1,256);
cdf_ref=zeros(1,256);
tmp=zeros(1,256);
final=zeros(m,n);
%a=0;
%b=0;
for k=1:m
for l=1:n
for r=0:255
if(input_img(k,l)==r)
pdf_main(1,r+1)=pdf(1,r+1)+1;
end
end
end
end
for k=1:m
for l=1:n
for r=0:255
if(ref_img(k,l)==r)
pdf_ref(1,r+1)=pdf(1,r+1)+1;
end
end
end
end
sum=0;
for i=1:256
sum=sum+pdf_main(1,i);
cdf_main(1,i)=sum;
end
sum=0;
for i=1:256
sum=sum+pdf_ref(1,i);
cdf_ref(1,i)=sum;
end
for i=1:256
for j=1:256
if cdf_main(1,i)==cdf_ref(1,j)
k=j;
break;
else if cdf_main(1,i)< cdf_ref(1,j)
k=j-1;
break;
end
end
end
tmp(1,i)=k;
end
for i=1:m
for j=1:n
for u=1:256
if input_img(i,j)== u
final_img(i,j)=tmp(1,u);
break;
end
end
end
end
subplot(3,3,1);
imshow(input_img);
title('Input image');
subplot(3,3,2);
plot(pdf_main);
title('PDF Input');
subplot(3,3,3);
plot(cdf_main);
title('CDF Input');
subplot(3,3,4);
imshow(ref_img);
title('Reference image');
subplot(3,3,5);
plot(pdf_ref);
title('PDF Reference');
subplot(3,3,6);
plot(cdf_ref);
title('CDF Reference');
subplot(3,3,7);
imshow(final_img);
title('Final image');
subplot(3,3,8);
plot(tmp);
title('Transformation function');
[MATLAB] Histogram Equalization program
final_img=imread('fig3.jpg'); input_img=imread('fig3.jpg'); [m n]=size(input_img); mn=m*n; pdf=zeros(1,256); cdf=zeros(1,256); tmp=zeros(1,256); final=zeros(m,n); %a=0; %b=0; for k=1:m for l=1:n for r=0:255 if(input_img(k,l)==r) pdf(1,r+1)=pdf(1,r+1)+1; end end end end sum=0; for i=1:256 sum=sum+pdf(1,i); cdf(1,i)=sum; end for i=1:256 tmp(1,i)=floor((cdf(1,i)/(mn))*255); end for i=1:m for j=1:n for k=0:255 if input_img(i,j)==k break; end end final_img(i,j)=tmp(1,k+1); end end subplot(2,2,1); imshow(input_img); title('Input image'); subplot(2,2,2); plot(pdf); title('PDF'); subplot(2,2,3); imshow(final_img); title('Equalized image'); subplot(2,2,4); plot(cdf); title('CDF');
[MATLAB] Gamma,Log and Negetive Trasformation Code
log_input=imread('fig3.jpg'); gamma_input=imread('fig6.jpg'); neg_input=imread('fig5.jpg'); %img=rgb2gray(inpt); %imview(img); [m n]=size(log_input); [o p]=size(gamma_input); [q r]=size(neg_input); log_opt=zeros(m,n); gamma_opt=zeros(o,p); neg_opt=zeros(q,r); for k=1:m for l=1:n log_opt(k,l)=30*log(double(log_input(k,l))); end end for k=1:o for l=1:p gamma_opt(k,l)=0.6*power(double(gamma_input(k,l)),0.98); end end for k=1:q for l=1:r neg_opt(k,l)=255-neg_input(k,l); end end subplot(3,2,1); imshow(uint8(log_input)); title('Original image'); subplot(3,2,2); imshow(uint8(log_opt)); title('Log Transformation'); subplot(3,2,3); imshow(uint8(gamma_input)); title('Original image'); subplot(3,2,4); imshow(uint8(gamma_opt)); title('Gamma Transformation'); subplot(3,2,5); imshow(uint8(neg_input)); title('Original image'); subplot(3,2,6); imshow(uint8(neg_opt)); title('Negetive Transformation');
Subscribe to:
Posts (Atom)