Coder Social home page Coder Social logo

bitmap's Introduction

Description

The C++ Bitmap Library for 8-bit per pixel bitmap image format.

Capabilities

  • Read/Write 8-bit Bitmap Images
  • Apply grayscale
  • Apply 3*3 filter on images
  • Apply threshold on images (between 0 and 1)
    explicit BitMap(const std::string& filename); //loading
    void save(const std::string& filename); //saving
    void applyThreshold(const float &threshold); // threshold
    void applyGreyScale(); // greyscale
    void applyFilter(const std::vector<int> &filter); // applyfilter 3x3
    void applyFilterFromFile(const std::string& filename); // from file.

Compatible

  • Linux
  • OSX
  • Windows (not compiled so far)
#include "bitmap.h"
#include <iostream>

int main(int argc, char *argv[])
{
    std::cout << argc << "\n";
    bool run = (argc > 1);
    if(!run)
    {
        std::cout << "No image path found" << "\n";
        return 0;
    }

    std::string filename = argv[1];
    try
    {
        BitMap image(filename);
        std::cout << "Image is loaded" << "\n";

        image.printHeaders();
        bool exit  = false;
        while (!exit) {
           char action;
           float threshold;
           std::string filter_filename, dummy;
           std::cout << "Enter a number to perfown following tasks." << "\n";
           std::cout << "1. Apply threadhold" << "\n";
           std::cout << "2. Apply filter from file" << "\n";
           std::cout << "3. Save in the same directory as output.bmp" << "\n";
           std::cout << "4. To exit." << "\n";

           std::cin >> action;
           std::getline(std::cin,dummy);

           switch (action) {
           case '1':
               std::cout << "Enter value between 0 and 1" << "\n";
               std::cin >> threshold;
               if(threshold >= 0 && threshold <= 1.0)
               {
                   image.applyThreshold(threshold);
               }
               else
               {
                    std::cout << "threshold must be between 0 and 1";
               }

               std::cout << "Threshold applied" << "\n\n";
               break;

           case '2':
               std::cout << "Enter complete path of the matrix file." << "\n";
               std::getline(std::cin, filter_filename);
               image.applyFilterFromFile(filter_filename);
               std::cout << "Filter applied" << "\n\n";
               break;

           case '3':
               image.save("ouput.bmp");
               std::cout << "Saved applied" << "\n\n";
               break;
           case '4':
               exit = true;
               break;
           default:
               break;
           }


        }

    }
    catch (std::runtime_error e)
    {
        std::cout << e.what() << "\n";
        run = false;
    }
    catch (...)
    {
        std::cout << "ERROR_OCCURED" << "\n";
        run = false;
    }

}

bitmap's People

Contributors

sumitjha295 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.