Thursday, July 3, 2025

Create color image using R, G and B three separate planes

 import cv2

import numpy as np

height, width = 300, 300

R = np.full((height, width), 255, dtype=np.uint8) # Red plane (fully red)

G = np.zeros((height, width), dtype=np.uint8) # Green plane (zero)

B = np.full((height, width), 100, dtype=np.uint8) # Blue plane (some blue)

color_image = cv2.merge([B, G, R])

cv2.imshow("Color Image from R, G, B Planes", color_image)

cv2.waitKey(0)

cv2.destroyAllWindows()

Draw image profile

 import cv2

import numpy as np

import matplotlib.pyplot as plt

image = cv2.imread('your_image.jpg', cv2.IMREAD_GRAYSCALE)

row = image.shape[0] // 2 # Middle row

profile = image[row, :] # Intensity values along that row

image_with_line = cv2.cvtColor(image, cv2.COLOR_GRAY2BGR)

cv2.line(image_with_line, (0, row), (image.shape[1], row), (0, 0, 255), 1)

cv2.imshow("Image with Profile Line", image_with_line)

plt.figure(figsize=(10, 4))

plt.title(f'Intensity Profile of Row {row}')

plt.plot(profile, color='black')

plt.xlabel('Column Index')

plt.ylabel('Intensity')

plt.grid(True)

plt.tight_layout()

plt.show()

cv2.waitKey(0)

cv2.destroyAllWindows()

Friday, March 14, 2025

How to install OPENCV package of python in Ubuntu

 First be sure that gedit is already installed in your system. 

If it is not installed, run this command 

                                sudo apt  install gedit  # version 46.1-3

Next run : 

                                sudo apt update

Now, run these following commands to install opencv in your ubuntu operating system.

sudo apt install libopencv-dev python3-opencv

Check opencv version:

                                python3 -c "import cv2; print(cv2.__version__)"


After installing, you can check wheather your program is properly running or not, you can simply write a sample code like....

To create python file : gedit p1.py

import cv2 img = cv2.imread("/home/arik/Downloads/image.jpeg", cv2.IMREAD_GRAYSCALE) cv2.imshow('image',img) cv2.waitKey(0) cv2.destroyAllWindows()

Here is the above given image:  




To run : python3 p1.py

If output is,


So, your installation is successfull.

Monday, May 13, 2024

Warshall Algorithm

 #include<iostream>

using namespace std;


int main()

{

    int n;

    cout<<"Enter total number of vertices"<<endl;

    cin>>n;

    //matrix

    int a[n][n];

    int i,j,k;

    cout<<"Input the value of adjacency matrix"<<endl;

    for(i=0;i<n;i++)

    {

        cout<<"Enter the value of "<<i+1<<"row";

        for(j=0;j<n;j++)

        {

            cin>>a[i][j];

        }

    }

    

    //display cost matrix

    for(i=0;i<n;i++)

    {

        for(j=0;j<n;j++)

        {

            cout<<a[i][j]<<" ";

        }

        cout<<endl;

    }

    // algo

    for(k=0;k<n;k++)

    {

    for(i=0;i<n;i++)

    {

        for(j=0;j<n;j++)

        {

                a[i][j]=a[i][j] || (a[i][k] && a[k][j]);

        }

    }

    }

    //diaplay 

    cout<<"output matrix"<<endl;

     for(i=0;i<n;i++)

    {

        for(j=0;j<n;j++)

        {

            cout<<a[i][j]<<" ";

        }

        cout<<endl;

    }

    

}

Floyd's Algorithm

 #include<iostream>

using namespace std;


int main()

{

    int n;

    cout<<"Enter total number of vertices"<<endl;

    cin>>n;

    //matrix

    int a[n][n];

    int i,j,k;

    cout<<"Input the value of adjacency matrix"<<endl;

    for(i=0;i<n;i++)

    {

        cout<<"Enter the value of "<<i+1<<"row";

        for(j=0;j<n;j++)

        {

            cin>>a[i][j];

        }

    }

    

    //display adjacency matrix

    for(i=0;i<n;i++)

    {

        for(j=0;j<n;j++)

        {

            cout<<a[i][j]<<" ";

        }

        cout<<endl;

    }

    //floyd algo

    for(k=0;k<n;k++)

    {

    for(i=0;i<n;i++)

    {

        for(j=0;j<n;j++)

        {

            if(a[i][j]>a[i][k]+a[k][j])

            {

                a[i][j]=a[i][k]+a[k][j];

            }

        }

    }

    }

    //diaplay 

    cout<<"output matrix"<<endl;

     for(i=0;i<n;i++)

    {

        for(j=0;j<n;j++)

        {

            cout<<a[i][j]<<" ";

        }

        cout<<endl;

    }

    

}

Tuesday, March 12, 2024

EMPLOYEE TABLE in ORACLE (RDBMS)

Q.EMPLOYEE TABLE


create table EMP(eid number, ename varchar2(20),age number,salary number,company varchar2(60));

insert into EMP values (1,'raju',30,30000,'TCS');

insert into EMP values (2,'indu',35,40000,'IBM');

insert into EMP values (3,'kalia',40,50000,'CTS');

select *

from EMP;

drop table EMP;


select * 

from EMP

where company='TCS';


select ename 

from EMP

where salary>=40000;


select ename 

from EMP

where age<=35 and salary>=40000;


select ename 

from EMP

where age<=35 or salary>=40000;


select min(salary)

from EMP;


select min(salary) as minimum_salary

from EMP;


select max(salary)

from EMP;


select max(salary) as maximum_salary

from EMP;


select avg(salary)

from EMP;


select avg(salary) as average_salary

from EMP;

++++++++++++++++++++++++++++++++++++++++++++++++++++++++

create table EMP(eid number, ename varchar2(20),age number,salary number,company varchar2(60));

insert into EMP values (1,'raju',30,30000,'TCS');

insert into EMP values (2,'indu',35,40000,'IBM');

insert into EMP values (3,'kalia',40,50000,'CTS');

select *

from EMP;

drop table EMP;


select * 

from EMP

where company='TCS';


select ename 

from EMP

where salary>=40000;


select ename 

from EMP

where age<=35 and salary>=40000;


select ename 

from EMP

where age<=35 or salary>=40000;


select min(salary)

from EMP;


select min(salary) as minimum_salary

from EMP;


select max(salary)

from EMP;


select max(salary) as maximum_salary

from EMP;


select avg(salary)

from EMP;


select avg(salary) as average_salary

from EMP;


select ename

from EMP

where salary=(select max(salary)

                from EMP);


select ename

from EMP

where salary=(select min(salary)

                from EMP);


select ename

from EMP

where salary>=(select avg(salary)

                from EMP);


select ename

from EMP

where age=(select max(age)

                from EMP);


select ename

from EMP

where salary>(select salary

                from EMP

                where ename='raju');

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

update EMP set company='TCS'

where eid=1;

select * from EMP;

update EMP set company='IBM'

where eid=2;

select * from EMP;

update EMP set company='CTS'

where eid=3;

select * from EMP;


update EMP set age=age+1;

select * from EMP;

Outlook, developed by Microsoft, is a widely used personal information manager that includes an email client, calendar, task manager, contact manager, note-taking, journal, and web browsing

 Outlook, developed by Microsoft, is a widely used personal information manager that includes an email client, calendar, task manager, conta...