About this blog

I feel this blog as a reflection of my thoughts to myself , and sometimes as a public diary, and the is my only friend to share my thoughts who says never a "oh no! ,you shouldn't....That is boring...."

linux లేబుల్‌తో ఉన్న పోస్ట్‌లను చూపుతోంది. అన్ని పోస్ట్‌లు చూపించు
linux లేబుల్‌తో ఉన్న పోస్ట్‌లను చూపుతోంది. అన్ని పోస్ట్‌లు చూపించు

If cheese do not show up your video on linux

 Check if sudo cheese work ?

If works, then add user to the "video" group (if exists)

then login afresh or (temporary )instantiate the group video .


Adjust screen brightness manually on Linux Ubuntu from terminal

 get the list of display devices using xrandr -q

brightness any number between 0 and 1

 xrandr --output eDP --brightness 0.7

Fractals generation using Octave parallelization for the cores

Install OCTAVE with Parallel and Image libraries, first .

Save the following in "fractalParallel.m" file
and attribute execution status using chmod


#!/usr/bin/octave-cli
pkg load parallel

M=0.012;
N=0.012;
sqbox=1000;
O=[0.143, -0.65];

X=O(1)+linspace(-M,M,sqbox);
Y=O(2)+linspace(-N,N,sqbox);

 numCores=nproc();
 inputs=vec( repmat(X, sqbox, 1) )+ i* repmat(Y, 1, sqbox)(:);
 F=pararrayfun(numCores, @selfsim, inputs );

F=reshape(F,[length(X) length(Y)]);
imwrite(F,'MandelbrotPar.tiff');




Save this function file in "selfsim.m"

 function [val]=selfsim(c,limit, Maxcount)
 limit=2;
 Maxcount=50;
 z=0;
 kk=0;
 while abs(z)  z=z^2+c;
  ++kk;
 endwhile
 val=1-kk/Maxcount;
endfunction

when AVD on AMD devices Ubuntu 16.04 not working under Radeon Gallium GPU

Source: https://android.stackexchange.com/questions/145437/reinstall-avd-on-ubuntu-16-04

Problem:

sh: 1: glxinfo: not found
sh: 1: glxinfo: not found
libGL error: unable to load driver: nouveau_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: nouveau
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  155 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  33
  Current serial number in output stream:  34

The crux is that AVD is using x86 libraries for all. but AMD based OS are having the Graphics drivers in lib64 folders. So link them using softlinks, ln -s

The following can be accessed from the URL above. but I am keeping the following lines in my blog as a backup.

"
I am using Android Studio 2.1.1 and Ubuntu 16.04 (x64). The following solved the problems ("sh: 1: glxinfo: not found" and "libGL error:..") for me.
  1. $ sudo apt-get install lib64stdc++6 (if it is not installed)
  2. $ cd ~/Android/Sdk/tools/lib64/libstdc++
  3. $ mv libstdc++.so.6 libstdc++.so.6.original
  4. $ ln -s /usr/lib64/libstdc++.so.6 ~/Android/Sdk/tools/lib64/libstdc++
  5. $ sudo apt-get install mesa-utils (if it is not installed)  
"

To pick out a matching picture by file hash codes md5sum

To pick out a matching picture by file metadata using ImageMagick as given the following website:

http://www.imagemagick.org/Usage/compare/#doubles



md5sum * | sort | awk {'print $2 " " $1'}  | uniq -Df 1

system 76 Ubuntu Nvidia graphics drivers

use only Nvidia 361 and no other versions  can help you on this.

Octave GUI version install through compile and dependency resolving

sudo apt-get install gcc g++ gfortran make libblas-dev liblapack-dev libpcre3-dev libarpack2-dev libcurl4-gnutls-dev epstool libfftw3-dev transfig libfltk1.3-dev libfontconfig1-dev libfreetype6-dev libgl2ps-dev libglpk-dev libreadline-dev gnuplot libgraphicsmagick++1-dev libhdf5-serial-dev openjdk-7-jdk libsndfile1-dev llvm-dev lpr texinfo libglu1-mesa-dev pstoedit libjack0 libjack-dev portaudio19-dev libqhull-dev libqrupdate-dev libqscintilla2-dev libqt4-dev libqtcore4 libqtwebkit4 libqt4-network libqtgui4 libsuitesparse-dev zlib1g-dev libxft-dev autoconf automake bison flex gperf gzip librsvg2-bin icoutils libtool perl rsync tar libosmesa6-dev libqt4-opengl-dev  
wget ftp://ftp.gnu.org/gnu/octave/octave-4.0.0.tar.gz  
tar xf octave-4.0.0.tar.gz  
rm octave-4.0.0.tar.gz  
cd octave-4.0.0/  
./configure  
make -j4  
sudo make install
I found this help on askubuntu.com 

Matlab on Android

Not exactly but you can run your same programme using Octave open source app.
I was surprised when it did the execution of a linear programming problem using glpk command with quite fastest output on the screen. Then I realized how powerful our phones with their quad core chips.
I use xiaomi redmi 2.
The app name is GNURoot Octave.
Also if you are interested in browsing all your device like a Linux machine use GNURoot Debian.

Updated copy disk files Linux bash shell script

#!/bin/bash

echo "Enter subject code:"
read pname

read -a arrayy <<< `cat /proc/mounts |grep sr0`
echo The files are being copied from: ${arrayy[1]}
cd ${arrayy[1]}

rm -r ~/tempsource
mkdir ~/tempsource

for jj in `find . -type f`
do
cp $jj ~/tempsource
done


chmod a+rwx ~/tempsource/*


cd ~/OLD_DATA
mkdir $pname
mv ~/tempsource/* $pname
echo $pname ": folder has been successfully created."

notify-send "Disk copy task Completed:"

echo "Insert Another Disk :"
eject

Unusual interest found in a particular question in "Stalk Overflow" on string separation

In the following link you can find a lot of users (nearly 2 thousand
unique entries)
trying hard on something that may be very easy for a PERL script expert.

http://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash

You know what all they might be interested in ?

'Web crawling' ; to catch the words and try to spam your inboxes for
advertising.

P.S: Some guys may be having different objectives than just crawling; I
reached this link when I was trying to grab the strings of mounted devices
folders for automatic database manipulation.

Windows కి కాలం చెల్లింది

ఈరోజు ల్లో ఎంత పెద్ద కంప్యూటర్ పరిశోధనా కేంద్రం ఐనా ప్రయోగాలన్నీ లినక్స్ OS మాధ్యమంగానే జరుగుతున్నాయి.
లార్జ్ హాడ్రన్ కొల్లైడర్ నుంచి సిలికాన్ వాలీ వరకూ అందరూ తమ తమ. Algorithms ను ముందుగా open source environment లోనే పరీక్షిస్తున్నారు.

Build octave linux in simple way if imagemagick is thtowing some bugs



# Install the dev packages needed to build octave.
sudo apt-get build-dep octave
# Get the official source package. Do this in a clean directory, because it will get polluted.
mkdir ~/myoctavebuild
cd ~/myoctavebuild
apt-get source octave
# Build it. This took roughly an hour for me.
cd octave-3.8.2
dpkg-buildpackage
# Either run it from the build directory:
./run-octave
# ...or install it over the official octave:
cd ..
# Now you are in myoctavebuild directory:
# The following first two lines install some compiled libraries:
sudo dpkg -i liboctave2_3.8.2-4_amd64.deb 

sudo dpkg -i octave-common_3.8.2-4_all.deb 

sudo dpkg --install octave_3.8.2-4_amd64.deb


DVD CD Disk copy to Hard drive for exclusively files and without folders Bash Shell script Ubuntu Linux

Here rowthu is my account username.
The directory where the disk folder is mounted is /media/rowthu

Before running this programme create a folder OLD_DATA in home directory

Script starts from here

#!/bin/bash

echo "Enter subject code:"
read pname

cd /media/rowthu
rm -r ~/tempsource
mkdir ~/tempsource

for jj in `find . -type f`
do
cp $jj ~/tempsource
done

chmod a+rwx ~/tempsource/*

cd ~/OLD_DATA
mkdir $pname
mv ~/tempsource/* $pname
echo $pname
echo " folder has been successfully created."
echo "Insert Another Disk :"
eject
# end of the program

fitting an exponentially decaying co-sine using differential equation

Octave or Matlab code for 
Sample function trial for fitting an exact data from exponentially decaying sine. 




##code starts from here
version:1 
x=-4:0.1:4;

u=exp(-2*x).*sin(pi*x+1);

du=exp(-2*x).*(pi*cos(pi*x+1)-2*sin(pi*x+1));
ddu=exp(-2*x).*(-4*pi*cos(pi*x+1)+(4-pi^2)*sin(pi*x+1));
beta=[-sum(du.*ddu); -sum(u.*ddu)];
A=[sum(du.*du), sum(u.*du);...
   sum(u.*du), sum(u.*u)];
param=A\beta;
b=param(1); c=param(2);
discrim=sqrt(b^2-4*c);
mu=(-b+discrim)/2;
nu=(-b-discrim)/2;
X=exp(mu.*x);
Y=exp(nu.*x);
beta=[sum(X.*u); sum(Y.*u)];
A=[sum(X.*X) sum(X.*Y);...
   sum(X.*Y) sum(Y.*Y)];
param=A\beta;
c=param(1); d=param(2);
v=real(c.*X+d.*Y);
plot(u-v); pause;  ##gives the pointwise error between original and fitted data.

Version:2 (with additive noise and central difference formula)
x=1:0.01:3;
dx=0.01;
noise=0; #1e-2*rand(size(x));
u=exp(-2*x).*sin(pi*x+1)+noise;
#u=200*exp(-2*x)+exp(3*x);
#du=exp(-2*x).*(pi*cos(pi*x+1)-2*sin(pi*x+1))+noise;
#ddu=exp(-2*x).*(-4*pi*cos(pi*x+1)+(4-pi^2)*sin(pi*x+1))+noise;

#du=diff(u); du=[2*du(1)-du(2) du];
du=u(3:end)-u(1:end-2); du=[2*du(1)-du(2) du 2*du(end)-du(end-1)];
du=du/dx/2;
ddu=du(3:end)-du(1:end-2); ddu=[2*ddu(1)-ddu(2) ddu 2*ddu(end)-ddu(end-1)];
#ddu=diff(du) ; ddu=[ddu 2*ddu(end)-ddu(end-1)];
ddu=ddu/dx/2;

######################################
##Begins Normal equations solving

beta=[-sum(du.*ddu); -sum(u.*ddu)];
A=[sum(du.*du), sum(u.*du);...
   sum(u.*du), sum(u.*u)];
param=A\beta;
b=param(1); c=param(2);
discrim=sqrt(b^2-4*c);
mu=(-b+discrim)/2;
nu=(-b-discrim)/2;
X=exp(mu.*x);
Y=exp(nu.*x);
beta=[sum(X.*u); sum(Y.*u)];
A=[sum(X.*X) sum(X.*Y);...
   sum(X.*Y) sum(Y.*Y)];
param=A\beta;
c=param(1); d=param(2);
v=real(c.*X+d.*Y);
#plot(x,v,'m');pause
semilogy(x,abs(u-v)./(abs(u)+eps),'b;Relative error;'); hold on;
semilogy(x,abs(u-v),'r;absolute error;');
title("blue:relatice red:absolute")
pause;



















ImageJ cannot open compressed DICOM Images --Solution

Just Place this jar file in plugins folder adn you will find a menu to handle whatever the way a DICOM was scaled (16 unsigned bit or 8 unsigned bit)


Bio-formats java jar package for ImageJ

fastest 3D version median using octave or matlab scilab

New updated version with faster 3D median:


A=ones(14,14,9);


nb=1;

New Version 2.0:

function C=fastmedian3D(A,nbd)
Author: Rowthu Vijayakrishna
Place: Dept. of Mathematics and Statistics, IIT Kanpur
Copyleft: Yes
Copyright: No
version: 2.0
[h w d]=size(A);
B=zeros((2*nbd+1)^3,h,w,d);

for j=-nbd:nbd
 for k=-nbd:nbd
  for l=-nbd:nbd
   v=(l+nbd+1 +(k+nbd)*(2*nbd+1) +(j+nbd)*(2*nbd+1)^2 );
   B(v,:,:,:)=shift(shift(shift(A,l,3),k,2),j,1);
  endfor;
 endfor;
endfor;
C=shiftdim(median(B));

####end of the function file



Old version:
Version 1.0

function C=fastmedian3D(A,nb)

[h w d]=size(A);
axlen=2*nb+1 ;
nb3d=zeros(axlen, axlen,axlen);
B=zeros( numel(nb3d),h,w,d );

tic
for j=1:h
 for k=1:w
  for l=1:d
   nblen=(min(j+nb,h) - max(1,j-nb)+1) *(min(k+nb,w) - max(1,k-nb)+1) *(min(l+nb,d) - max(1,l-nb)+1) ;
   B(1:nblen,j,k,l)=A( max(1,j-nb):min(j+nb,h),max(1, k-nb):min(k+nb,w) ,max(1,l-nb):min(l+nb,d) )(:);

  endfor;
 endfor;
endfor;
C=zeros(h,w,d);
C(:,:,:)=median(B)(1,:,:,:);
size(C)
toc

Still not the fastest

Convert Nifti (.nii) images to png or jpeg or tif

Install Imagej   Imagej
and use the plugin  Nifti jar  to open Nifti files.
( place it in plugins folder located at /home/youruser/.imagej/plugins/  and then restart imagej to see it in import menu)

And then save them as sequence in whatever the format you wish.

avconv any video to 3gp format

In the following ,  the switch "-strict experimental"  is required only for aac decoding.
for rest of the formats it is not necessary.
bitrate notation in kbytes is compulsary or else mention in full number of  bytes.

avconv -i   inputfilenmae.mp4   -s   qcif   -vcodec h263   -r 10  -b 180k -ab 64k  -acodec   aac -strict experimental   -ac  1   -ar 22050     outputfilename.3gp

octave matlab code for multiple thresholding an image using histogram peaks

The following code converts an image histogram into finitely sparse histogram by using multiple thresholds that appear in histogram as peaks.

Input image in tif format:



code begins here:

clear all
#### Automatic way to make histogram of an image
#### highly sparse with thresholds observed in Histogram
#### Author: Rowthu Vijayakrishna
#### Date: 02-August-2014
#### Place:Dept. of Mathematics,IIT Kanpur

A=imread('Documents/octave/testIMGS/greyshade.tif');
for jump=1:3 ###jump is the maximum seperation in threshold values
do
B=A;
H=imhist(A,256);
plot(H);pause;
 for i=1:size(A,1)
    for j=1:size(A,2)
       if H(1+A(i,j))<H(1+uint8(jump+A(i,j)))
          A(i,j)=uint8(A(i,j)+jump);1
        else if H(1+uint8(A(i,j)-jump))>H(1+A(i,j))
               A(i,j)=uint8(A(i,j)-jump);2
             endif;
        endif;
    endfor;
endfor;
until max(abs(B-A)(:))==0
endfor;

imwrite(A,'temp.tif');
printf('End of the programme\n');