Saturday, August 26, 2017

360 image

Hello there

it is a 360 imaging test


Friday, July 30, 2010

Being a graduate ..

SA,
It has been while and a lot of events happened .. exams, working in GP and documentation, final seminar and being a graduate :D


I'll talk briefly about each.


Exams:
--------


The last exams ever, it was a new feeling :D, I used to expect next year with new exams waiting for me, but this time was different, there're nothing waiting and it's the last ever isA :D
Exams passed peacefully thanks to Allah and 2 weeks of hard work began ;)


Graduation project finishing:
----------------------------------


2 weeks of hard work, meeting daily from the morning till afternoon, spent between documentation finishing, program integration and program interface.
We worked hard but thanks to Allah it wasn't in vain :)


Final Seminar:
-----------------


5/7/2010 The big day :D
We were the first group at 9 am, I was there about 8 am, waited for Ahd and Reham to come, we made quick rehearsal and we began welcome our beloved who came early specially to attend our seminar, they were Ahd's parents, Reham's mother and my school friends (Abeer, Basma and Nermeen) I'm still feeling grateful for their attendance they made my day .. may Allah bless you dear friends (L)


Dr.Mohammad Roshdy, and an engineer from a company formed the committee which discussed the GP. 
Thanks to Allah it was great :)
and the whole day was awesome, many thanks to those who attended and who encouraged us :)


Being a graduate:
---------------------
22/7/2010 the results was announced but to get it we had to call a number and pay a lot of money to get it. I refused :D I believed that it's Profiteering as there was a promise to publish the results on the official website 
directly, I decided to wait for the publishing.
Thanks to Allah I didn't wait much, On Friday 23/7/2010 my friend reham called me
and told me that T.A. Eslam have attached the results in a topic on our forum (CIS Club).
Thanks to Allah the result was satisfying my grade was Very Good with honor :)






and finally I'm a graduate, I called myself Miss.Graduate :D


but I'm not only a graduate I'm jobless too :(, I'm searching and I've sent to many 
companies and nothing new :(
I wish to find a good job as soon as possible, as this empty life is bad.

Sunday, May 23, 2010

My first splash screen - wow :D

SA,


Do you now about splash screen ?! .. it's that image that appears when you load a program before the main interface appears to you, just like that which appears when you open Microsoft Word for example.


So what !! :D
Well .. we are expecting that the the program of our Graduation project would take time to load and it won't be nice to let the user wait without a splash screen ;)


From here we decided to make one, thanks to Allah I've designed the splash screen using Photoshop and test it using this code .
and finally .. it WORKS ! :D:D
My first splash screen worked successfully thanks to Allah.


Here's the design ;)


Tuesday, April 27, 2010

Being the FIRST for the FIRST time

SA,
It has been while I know :D but Ce la vie :D


Last Saturday 24/4/2010 carried good news for me.
Every Saturday is the day of the selected tracks provided by ITI and some companies, my track is Enterprise IBM where we learn Java (standard and enterprise edition), I liked this track though it's not easy and it's huge some how compared to the course period.
But I really liked it :D, also our instructor Eng.Mahmoud Atef is helpful and caring, and I feel that he's doing his best.
In sum I feel that I'm lucky to be in this track with this instructor (as he's the best among the three who give this course).


Back to Last Saturday :D
I woke up a bit late this day so when I reached the college the instructor was there but luckily he hadn't been started yet, one of my colleagues who was next to me told me: "hey you're the first ;)",she meant in the midterm exam, I don't why I felt nothing :D, after a while Eng.Mahmoud said: " you're the first,  you're Fatma right?!" I said: "yes", he continued: "you're the first over the 3 groups".
Good news but still not astonished not very happy not sad, I felt nothing again :D
It's the first time for me to be the FIRST :D. Yes I guess so, I can't remember being the first before :D
Although after then I felt happy :D but I told myself that I'm the best of worst, as the grades' level wasn't so high it was bad actually :D
But you know what! as one of my friends told me "Don't despise it, you are the first and that what matters!".
Yes that what matters.
That's why I feel happy when I remember this day :), I wish I can do better isA.
Thanks to Allah :)


So finally I want you to  remember that --> Don't despise any little success, it may lead you to a victory some day ;)

Sunday, January 17, 2010

Study Hacks - A great article (Y)

SA,
Hope you are all fine ? :D
EXAMS !!!!
The topic most of us are talking about those days :/
and of course, most of us talk about studying hard, spending the night studying, tension and the bad subjects the drives you mad...etc.
well as my friend "Noran" used to say "It's not the load that breaks u down...it's the way u carry it".
Thats true :D
let me say that over the past years I spent in studying I used to study few hours coz I get bored fast :D
and thanks to Allah my grades was very good :)
Sometimes I feel guilty about this wasted time when I don't study, but when I read this article I realised that I was right and I won't feel guilty anymore, because the time I don't study in is not wasted time, it's a recharging time ;) 
Here's the article


http://calnewport.com/blog/2007/07/26/the-straight-a-gospels-pseudo-work-does-not-equal-work/


Thanks to "Abdelrahman Zakaria" who published this link.


and thanks for all those who read this :D:D

Thursday, December 17, 2009

Copying is not a theft !!!

Actually I don't know to what extent is that right :D 





I used to copy many things but with no intention of theft or abuse, it was always for benefit and learning sake.
Lately I keep in wondering is this a bad deed or immoral !!
I keep wondering and ... copying, except there's another way rather than copying to get what I need.


What do you think about this ?!!




Saturday, December 12, 2009

How to detect if bitmap is grayscale ?!

SA :)
Here we're again talking about images, it's all about image processing course :D
well I needed my package to do a specific action depending on whether the image is colored or grayscale.
So, how to achieve this ?!
I searched a lot but I reached nothing :S
so I had to loop the pixels of the image and make sure that the RGB components of each pixel are equal to detect it as grayscale.
How bad !!
But finally I discovered another simple method ;)
consider you have a Bitmap object called Myimage.
the condition of grayscale is( Myimage.Palette.Flags = = 2)
so if this condition is true Myimage is grayscale, else it's colored :D
Yes..That easy ;)
Enjoy it ;) :D

Friday, December 11, 2009

Adjusting controls in Forms - Efficient method ;)

SA :)
Finally there's an efficient way to adjust your controls in the form and to keep their relative positions and sizes.
review this and this :D


this method is very easy with perfect performance ;)


let's see a sample code for this:


    public partial class Form1 : Form
    {
        int oldHeight = 299, oldWidth = 436;
        int newHeight, newWidth;
        float verticalScale, horizontalScale;


        public Form1()
        {
            InitializeComponent();
        }


         private void Form1_Resize(object sender, EventArgs e)
        {


            newHeight = this.Height;
            newWidth = this.Width;
            verticalScale = (float)newHeight / oldHeight;
            horizontalScale = (float)newWidth / oldWidth;


            foreach (Control c in this.Controls)
            {
                c.Height = (int)(c.Height * verticalScale);
                c.Width = (int)(c.Width * horizontalScale);
                c.Top = (int)(c.Top * verticalScale);
                c.Left = (int)(c.Left * horizontalScale);
            }


            oldWidth = this.Width;
            oldHeight = this.Height;
        }
    }


all you have to do is to copy the parameters in your form, and set the oldHeight and oldWidth by the current Height and Width of your form in design mode.


        int oldHeight = 299, oldWidth = 436;
        int newHeight, newWidth;
        float verticalScale, horizontalScale;


and then copy the code in the Form1_Resize() in your form resize handler and enjoy the results ;)

Tuesday, December 1, 2009

Unsafetey is better sometimes :D

SA,


As the Image processing package which we develop in Image processing course gets bigger its performance gets slower, and the need to use unsafe code increases.
So I took the risk :D and started to modify all my functions in that package to convert it from safe to unsafe code, and since I’ve faced some problems and have learned some things about bitmaps I’ve never learned I decided to write them down for those who may face the same problems.


The PDF version is here.


So let’s start.


Safe VS Unsafe:
-Safecode is the code that runs under CLR. The memory management of safe code is handled by CLR.
-Unsafe code is direct memory access or file I/O or database operations. Here you need to manage memory yourself by calling dispose on objects.

For more about this :  http://www.dotnetspider.com/forum/155077-What-Safecode-unsafe-code.aspx


Before getting started:
We need to tell the C# project to allow unsafe code, R.click on the project and choose properties, then:









Also don’t forget to include this library.


using System.Drawing.Imaging;




What does this code look like?!


Let’s take the following function as an example, it’s used to convert image to grayscale.


private Bitmap GrayScale(Bitmap bmpimg)

        {
BitmapData bmpData = bmpimg.LockBits(new Rectangle(0, 0, bmpimg.Width, bmpimg.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            int remain = bmpData.Stride - bmpData.Width * 3;

            unsafe
            {
                byte* ptr = (byte*)bmpData.Scan0;

                for (int i = 0; i < bmpData.Height; i++)
                {
                    for (int j = 0; j < bmpData.Width; j++)
                    {

ptr[0] = ptr[1] = ptr[2] = (byte)((ptr[0] + ptr[1] + ptr[2]) / 3);
                        ptr += 3;
                    }
                    ptr += remain;
                }
            }
            bmpimg.UnlockBits(bmpData);
            return bmpimg;
        }




To access the image pixels with pointers you’ve to lock its bits first, using the LockBits function



BitmapData bmpData = bmpimg.LockBits(new Rectangle(0, 0, bmpimg.Width, bmpimg.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);




 This function takes a rectangle as a parameter to determine the rectangle that represents the portion you need to lock in this image, also it takes the ImageLockMode and the PixelFormat and returns an object of BitmapData.




Most of time we use this value “Format24bppRgb” as PixelFormat, which means that each pixel contains 24 bits (3 bytes) and colored by RGB system. RGB color (24-bit) pixel values are stored with bytes as BGR (blue, green, red), byte 1 for Blue, byte 2 for Green and byte 3 for Red. (http://en.wikipedia.org/wiki/BMP_file_format)



A lot of formats are available in this enumerator, see more about them here


In my application I used the “Format24bppRgb” and “Format8bppIndexed” only which I’ll discuss later in this paper.


Now give me your attention in this part,
The basic layout of a locked bitmap array is






In brief let me say that the size of pixels row of an image must be a multiple of 4 and since it’s not the case in all images so padding is usually added at the end of each row.


Ex: an image of format 24bpp with width 17 pixels has a stride of 52 bytes, 51 bytes (3*17) and 1 bit as padding.



After understanding this concept let’s see the rest of the code.



int remain = bmpData.Stride - bmpData.Width * 3;




remain represents the padding magnitude.
Then to start using pointers you have to write your code in an unsafe block.




Unsafe
{……


Now we need a pointer to the first pixel of the image 




byte* ptr = (byte*)bmpData.Scan0;


Where scan0 is a property of BitmapData which gets or sets the address of the first pixel in the image, note that I said pixel not byte, this means if the image is of PixelFormat “Format24bppRgb” then ptr is a pointer to an array of 3 bytes.
Now we need to loop on the image pixels and change their values to grayscale, we use these nested for loops to do so



  for (int i = 0; i < bmpData.Height; i++)
  {
    for (int j = 0; j < bmpData.Width; j++)
     {
ptr[0] = ptr[1] = ptr[2] = (byte)((ptr[0] + ptr[1] + ptr[2]) / 3);
      ptr += 3;
     }
    ptr += remain;
 }


Note this line



ptr += remain;




Where we add the padding value (remain) to go to the next line and get the next pixel correctly.
And finally




bmpimg.UnlockBits(bmpData);
return bmpimg;
}




We unlock the bits of the image using UnlockBits method which take the BitmapData object as a parameter and by then your image is converted to grayscale.
You can use this example to apply the unsafe code in many other functions of image processing package the concept is the same.


Take care of the pixel format:


 “Image is an array of pixels that carries the color intensities”, yes sometimes, but it’s not always the case.
There’s a format of images called indexed images where the image consists of 2 parts, pixel data and color model data. Each pixel gets its color equivalent by asking the color model for the color corresponding to the pixel’s index.
In Bitmap object the color map is stored in what’s called palette. To get the array of colors in palette, simply:


Color[] myPalette = Pic.Palette.Entries;




Where Entries is the color array in palette.


                                                                              http://en.wikipedia.org/wiki/Indexed_color




So if your image PixelFormat is “Format8bppIndexed”, don’t forget:


1- Lock the image by the same PixelFormat and if you don’t know the format of the input image you can use this




BitmapData orgImgData = Pic.LockBits(new Rectangle(Point.Empty, Pic.Size), ImageLockMode.ReadWrite, Pic.PixelFormat);


Where Pic is the image sent to the function.

2-The padding value will be as follows



int remain = bmpData.Stride - bmpData.Width;


as the pixel is represented by only one byte.


3-  To get the color components of the pixel, construct an array of Color from the Palette.Entries:



Color[] myPalette = Pic.Palette.Entries;


And to get the red component for example:




myPalette[orgImgPtr[0]].R







|--------------------------------------------------------|
  |             Hope this was useful : )               |
|--------------------------------------------------------|




References:
http://www.vcskicks.com/fast-image-processing.html
http://www.devasp.net/net/articles/display/453.html
http://www.bobpowell.net/lockingbits.htm
http://www.codersource.net/csharp_image_Processing.aspx
http://www.cylekx.net/help/indexed_images.htm
http://msdn.microsoft.com/en-us/library/ms229672.aspx


Friday, November 27, 2009

TableLayoutPanel control - is useful ;)

SA,
Do you remember this topic ?! Smart Layout !!!
I've found a good solution it's simple .. I wonder how I couldn't I notice this !!
it's using TableLayoutPanel control in your Form to adjust the position of your controls :D
yes!! that easy :D
I need to say a big Thanks to my friend Manal (she's a fresh graduate and working 
now) who advised me to use this control :)

To know more about this control and how to use it, check this :)
http://en.csharp-online.net/TableLayoutPanel