Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1070275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:32:18+00:00 2026-05-16T20:32:18+00:00

I have three classes, TImageProcessingEngine , TImage and TProcessing TImageProcessingEngine is the one which

  • 0

I have three classes, TImageProcessingEngine, TImage and TProcessing

TImageProcessingEngine is the one which i am using to expose all my methods to the world.

TImage is the one i plan to use generic image read and image write functions.

TProcessing contains methods that will perform imaging operations.

class TImageProcessingEngine
{
    public:
        TImage* mpImageProcessingEngine;

};

class TImage
{
    public:
        int ReadImage();
        int WriteImage();

    private:
            //a two dimensional array holding the pixel values
        tImageMatrix*  mpImageMatrix;
};

class TProcessing
{
    public:
        int ConvertToBinary();
        int ConvertToGrayScale();
};

My question is how do i access the object mpImageMatrix in class TProcessing? So that my calling application can use the following

TImageProcessingEngine* vEngine = new TImageProcessingEngine;

//Converts an input gray scsale image to binary image
vEngine->ReadImage().ConvertToBinary();

//Write the converted image to disk
vEngine->WriteImage();

delete vEngine;
vEngine = NULL;

//During this whole processing internally, 
//the image is read in to `mpImageMatrix` 
//and will also be holding the binarised image data, 
//till writing the image to disk.

Or Do you recommend any other approach to my class design?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:32:18+00:00Added an answer on May 16, 2026 at 8:32 pm

    I would certainly recommend a different implementation, but let’s check the design first.

    I don’t really understand the added value of TImageProcessingEngine, it doesn’t bring any functionality.

    My advice would be quite simple in fact:

    • Image class, to hold the values
    • Processing class (interface), to apply operations
    • Encoder and Decoder classes (interfaces), to read and write to different formats

    It does make sense for the Processing class to have access to the images internal only if you can get efficiency from it (which is likely), in this case you can simply makes Processing friend and having it unpack the values for its derived

    class Image
    {
    public:
      Image();
    
      void Accept(Processing& p);
      void Encode(Encoder& e) const; // Image is not modified by encoding
    
      void Decode(Decoder& d); // This actually resets the image content
    
    private:
      friend class Processing;
    
      size_t mHeight;
      size_t mWidth;
      std::vector<Pixel> mPixels; // 2D array of Pixels
    };
    
    class Processing
    {
    public:
      void apply(Image& image)
      {
        this->applyImpl(image.mHeight, image.mWidth, image.mPixels);
      }
    
    private:
      virtual void applyImpl(size_t h, size_t w, std::vector<Pixel>& pixels) = 0;
    };
    

    Encoder and Decoder follow the same principle.

    Note how I never needed an explicit pointer, and the guaranteed correctness that results from it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three classes, one main class, one GUI class which uses awt+swing to
I have three classes which all make different works but I need to run
I have three classes that I am using and have shortened for ease of
I have three classes: PurchaseOrder, PurchaseOrderLine, Item PurchaseOrder children are PurchaseOrderLine which is related
I have three classes that all have a static function called 'create'. I would
I have three classes: ClassA , ClassB , ClassC . ClassC extends ClassB which
I have three classes (House, Room, Address) which are persistent (Mapped with JPA/Hibernate) @Entity
I have three classes called Broker , Instrument and BrokerInstrument . using Iesi.Collections.Generic; public
I have three classes which implement the same protocol, and have the same parent
I have three classes: SomeThing, SomeOtherThing, and YetAntherThing. All three have an identical member

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.