Posts

Showing posts from February, 2021

Prime_No_cpp

 #include<simplecpp> main_program{ int n; cin>>n; int divisor = 2; bool divisor_found = false; // No divisor is found // Check from all the way from 2 to n-1 // If any number divides n set divisor_found to true repeat(n-2){ if (n % divisor == 0) divisor_found = true; divisor += 1; }     if (!divisor_found) cout<<"Prime.\n";     else cout<<"Composite.\n"; }

How to multiply cpp

 #include<simplecpp> main_program{ int d; cin>>d; int N; cin>>N; int carry = 0; repeat(N){     int m_i;     cin>>m_i;     int prod;     prod = m_i * d + carry;     int p_i = prod % 10;     carry = prod/10;     cout<<p_i<<endl;         }     if (carry != 0) cout<<carry<<endl; }

SPI and CPI cpp

 #include<simplecpp> main_program{ int N,credit,total_credit; char grade;     double SPI,CPI;     double numerator_SPI = 0, denominator_SPI = 0, numerator_CPI = 0,denominator_CPI = 0;     cin>>N;     repeat(N){         //int num = 1;         //cout<<" Enter the grade of "<<num<<" course: ";         cin>>grade;         cin>>credit;         cout<<grade<<" "<<credit<<"\n";         int num_grade = 'K' - grade;         numerator_SPI += (num_grade * credit);         denominator_SPI += credit;     }     cout<<numerator_SPI<<" "<<denominator_SPI;     cin>>CPI;     cin>>total_credit;     cout<<CPI<<" "<<total_credit<<"\n"; ...

Ground Detection(segmentation) for Autonomous Driving

close all ; % clear all; clc; resnet50(); outputFolder = fullfile( '/home/hyphen/Downloads' , 'data_road_224' ); imgDir = fullfile(outputFolder, 'training' , 'image_2' ); imds = imageDatastore(imgDir); %auimds = augmentedImageDatastore([375 1242 3],imds); I = readimage(imds,1); I = histeq(I); imshow(I) classNames = [ "rightroad" "leftroad" "environment" ]; labelIDs = kittiPixelLabelIDs(); labelDir = fullfile(outputFolder, 'training' , 'gt_image_2' ); % imds1 = imageDatastore(labelDir); % pxds1 = augmentedImageDatastore([375 1242 3],imds1); % % filename = '/tmp/data_road/training/gt1'; % pxds2 = imwrite(pxds1,filename); pxds = pixelLabelDatastore(labelDir,classNames,labelIDs); C = readimage(pxds,1); cmap = kittiColorMap; B = labeloverlay(I,C, 'ColorMap' ,cmap); imshow(B) pixelLabelColorbar(cmap,classNames); tbl = countEachLabel(pxds) % Prepare Training, Validation, and Test Sets...

Improved License Plate Localization

1.) Localization: clear all; close all; clc; rgb = imread("HPIM0929.JPG"); figure imshow(rgb) gray = rgb2gray(rgb); figure imshow(gray) resized = imresize(gray,[480 640]); figure imshow(resized) tophat = imtophat(resized,strel('rectangle',[3 25])); figure imshow(tophat) T = graythresh(tophat); BW = imbinarize(tophat,T); figure imshow(BW) open = imopen(BW,strel('arbitrary',[1 1 1 1;1 1 1 1])); figure imshow(open) closed = imclose(open,strel('rectangle',[3 11])); figure imshow(closed) 2.) Optimal SE(structuring element) clear all; close all; clc; rgb = imread('4.JPG'); gray = rgb2gray(rgb); resize = imresize(gray,[240 320]); [rows, columns] = size(resize); if rows == 240 && columns == 320 for i = 0:15 tophat = imtophat(gray,strel('rectangle',[3 13])); binary = imbinarize(tophat); open = imopen(binary,de2bi(i,4)); closed = imclose(open,strel('rectangle',[3 8])); figure imshow(closed) end elseif rows == 319 && column...